29 $this->entitySnapshot = $this->createPartialMock(
31 [
'isModified',
'registerSnapshot']
34 $this->entityRelationComposite = $this->createPartialMock(
53 $object = $this->createPartialMock(
54 \
Magento\Catalog\Model\Product::class,
55 [
'getOrigData',
'__wakeup',
'beforeSave',
'afterSave',
'validateBeforeSave']
58 $object->setEntityTypeId(1);
60 $object->setData($key,
$value);
62 $object->expects($this->any())->method(
'getOrigData')->will($this->returnValue($productOrigData));
74 $backendModel = $this->createPartialMock(
85 $backendModel->expects(
90 $this->returnValue([
'test_table' => [[
'value_id' => 0,
'attribute_id' =>
$attributeCode]]])
93 $backendModel->expects($this->any())->method(
'isStatic')->will($this->returnValue(
false));
94 $backendModel->expects($this->never())->method(
'getEntityValueId');
97 $attribute->expects($this->any())->method(
'getBackend')->will($this->returnValue($backendModel));
101 ->disableOriginalConstructor()
106 $this->entitySnapshot->expects($this->once())->method(
'isModified')->willReturn(
true);
107 $this->entitySnapshot->expects($this->once())->method(
'registerSnapshot')->with($object);
109 $this->entityRelationComposite->expects($this->once())->method(
'processRelations')->with($object);
112 \
Magento\Eav\Model\Entity\VersionControl\AbstractEntity::class,
115 'entitySnapshot' => $this->entitySnapshot,
116 'entityRelationComposite' => $this->entityRelationComposite,
119 'entityTable' =>
'entityTable',
126 $model = $this->getMockBuilder(\
Magento\Eav\Model\Entity\VersionControl\AbstractEntity::class)
128 ->setMethods([
'_getValue',
'beginTransaction',
'commit',
'rollback',
'getConnection'])
131 $model->expects($this->any())->method(
'_getValue')->will($this->returnValue(
$eavConfig));
134 $eavConfig->expects($this->any())->method(
'getAttribute')->will(
135 $this->returnCallback(
142 $model->isPartialSave(
true);
146 public function testSaveNotModified()
151 $object = $this->createMock(\
Magento\Catalog\Model\Product::class);
154 \
Magento\Eav\Model\Entity\VersionControl\AbstractEntity::class,
156 'entitySnapshot' => $this->entitySnapshot,
157 'entityRelationComposite' => $this->entityRelationComposite,
162 $model = $this->getMockBuilder(\
Magento\Eav\Model\Entity\VersionControl\AbstractEntity::class)
164 ->setMethods([
'beginTransaction',
'commit'])
167 $this->entitySnapshot->expects($this->once())->method(
'isModified')->willReturn(
false);
168 $this->entitySnapshot->expects($this->never())->method(
'registerSnapshot');
170 $this->entityRelationComposite->expects($this->once())->method(
'processRelations')->with($object);
_getAttributeMock($attributeCode, $attributeSetId)