示例#1
0
 public function testGetAffectedFields()
 {
     $valueId = 2345;
     $attributeId = 345345;
     $attribute = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute', ['getBackendTable', 'isStatic', 'getAttributeId', 'getName', '__wakeup'], [], '', false);
     $attribute->expects($this->any())->method('getName')->will($this->returnValue('image'));
     $attribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($attributeId));
     $attribute->expects($this->any())->method('isStatic')->will($this->returnValue(false));
     $attribute->expects($this->any())->method('getBackendTable')->will($this->returnValue('table'));
     $this->model->setAttribute($attribute);
     $object = new \Magento\Framework\DataObject();
     $object->setImage(['images' => [['value_id' => $valueId]]]);
     $object->setId(555);
     $this->assertEquals(['table' => [['value_id' => $valueId, 'attribute_id' => $attributeId, 'entity_id' => $object->getId()]]], $this->model->getAffectedFields($object));
 }
示例#2
0
 public function testGetAffectedFields()
 {
     $valueId = 2345;
     $attributeId = 345345;
     $attribute = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute', ['getBackendTable', 'isStatic', 'getAttributeId', 'getName', '__wakeup'], [], '', false);
     $attribute->expects($this->any())->method('getName')->will($this->returnValue('image'));
     $attribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($attributeId));
     $attribute->expects($this->any())->method('isStatic')->will($this->returnValue(false));
     $attribute->expects($this->any())->method('getBackendTable')->will($this->returnValue('table'));
     $this->attributeRepository->expects($this->once())->method('get')->with('media_gallery')->willReturn($attribute);
     $object = new \Magento\Framework\DataObject();
     $object->setImage(['images' => [['value_id' => $valueId]]]);
     $object->setId(555);
     $this->assertEquals([\Magento\Catalog\Model\ResourceModel\Product\Gallery::GALLERY_TABLE => [['value_id' => $valueId, 'attribute_id' => 345345, 'entity_id' => $object->getId()]]], $this->model->getAffectedFields($object));
 }