Exemplo n.º 1
0
 public function testGetFields()
 {
     $mainTable = 'main_table';
     $expectedDescribedTable = 'described_table';
     $this->resource->expects($this->any())->method('getMainTable')->willReturn($mainTable);
     $this->connection->expects($this->once())->method('describeTable')->with($mainTable)->willReturn($expectedDescribedTable);
     $this->assertEquals($expectedDescribedTable, $this->entityMetadata->getFields($this->model));
     //get from cached
     $this->connection->expects($this->never())->method('describeTable');
     $this->assertEquals($expectedDescribedTable, $this->entityMetadata->getFields($this->model));
 }
Exemplo n.º 2
0
 /**
  * Check is current entity has changes, by comparing current object state with stored snapshot
  *
  * @param AbstractModel $entity
  * @return bool
  */
 public function isModified(AbstractModel $entity)
 {
     if (!$entity->getId()) {
         return true;
     }
     if (!isset($this->snapshotData[get_class($entity)][$entity->getId()])) {
         return true;
     }
     $data = array_intersect_key($entity->getData(), $this->entityMetadata->getFields($entity));
     if ($data !== $this->snapshotData[get_class($entity)][$entity->getId()]) {
         return true;
     }
     return false;
 }