Exemplo n.º 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));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function isModified(DataObject $entity)
 {
     $result = parent::isModified($entity);
     if (!$result && !$entity->getIsCustomerSaveTransaction() && $this->isAddressDefault($entity)) {
         return true;
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Checks if entity was modified
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return bool
  * @codeCoverageIgnore
  */
 protected function isModified(\Magento\Framework\Model\AbstractModel $object)
 {
     return $this->entitySnapshot->isModified($object);
 }