33 private $attributeResourceModel;
38 private $searchWeightPlugin;
45 $this->config = $this->getMockBuilder(\
Magento\Framework\Search\Request\Config::class)
46 ->setMethods([
'reset'])
47 ->disableOriginalConstructor()
49 $this->attribute = $this->getMockBuilder(\
Magento\Framework\Model\AbstractModel::class)
50 ->setMethods([
'isObjectNew',
'dataHasChangedFor'])
51 ->disableOriginalConstructor()
52 ->getMockForAbstractClass();
53 $this->attributeResourceModel = $this->getMockBuilder(\
Magento\Catalog\Model\
ResourceModel\Attribute::class)
55 ->disableOriginalConstructor()
61 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
65 'config' => $this->config,
72 $this->attribute->expects(self::once())->method(
'isObjectNew')->willReturn(
true);
73 $this->attribute->expects(self::once())->method(
'dataHasChangedFor')->with(
'search_weight')->willReturn(
false);
74 $this->config->expects(self::once())->method(
'reset');
75 $this->searchWeightPlugin->aroundSave($this->attributeResourceModel, $this->closure, $this->attribute);
80 $this->attribute->expects(self::once())->method(
'isObjectNew')->willReturn(
true);
81 $this->attribute->expects(self::once())->method(
'dataHasChangedFor')->with(
'search_weight')->willReturn(
true);
82 $this->config->expects(self::once())->method(
'reset');
83 $this->searchWeightPlugin->aroundSave($this->attributeResourceModel, $this->closure, $this->attribute);
88 $this->attribute->expects(self::once())->method(
'isObjectNew')->willReturn(
false);
89 $this->attribute->expects(self::once())->method(
'dataHasChangedFor')->with(
'search_weight')->willReturn(
true);
90 $this->config->expects(self::once())->method(
'reset');
91 $this->searchWeightPlugin->aroundSave($this->attributeResourceModel, $this->closure, $this->attribute);
96 $this->attribute->expects(self::once())->method(
'isObjectNew')->willReturn(
false);
97 $this->attribute->expects(self::once())->method(
'dataHasChangedFor')->with(
'search_weight')->willReturn(
false);
98 $this->config->expects(self::never())->method(
'reset');
99 $this->searchWeightPlugin->aroundSave($this->attributeResourceModel, $this->closure, $this->attribute);
testSaveNotNewAttributeWithChangedProperty()
testSaveNotNewAttributeWithNotChangedProperty()
testSaveNewAttributeWithChangedProperty()