Example #1
0
 public function testIsModified()
 {
     $entityId = 1;
     $data = ['id' => $entityId, 'name' => 'test', 'description' => '', 'custom_not_present_attribute' => ''];
     $fields = ['id' => [], 'name' => [], 'description' => []];
     $modifiedData = array_merge($data, ['name' => 'newName']);
     $this->model->expects($this->any())->method('getId')->willReturn($entityId);
     $this->entityMetadata->expects($this->exactly(2))->method('getFields')->with($this->model)->willReturn($fields);
     $this->model->setData($data);
     $this->entitySnapshot->registerSnapshot($this->model);
     $this->model->setData($modifiedData);
     $this->assertTrue($this->entitySnapshot->isModified($this->model));
     $this->entitySnapshot->registerSnapshot($this->model);
     $this->assertFalse($this->entitySnapshot->isModified($this->model));
 }
Example #2
0
 /**
  * Checks if entity was modified
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return bool
  */
 protected function isModified(\Magento\Framework\Model\AbstractModel $object)
 {
     return $this->entitySnapshot->isModified($object);
 }