Skip to content
Permalink
Browse files

Add a method to get all original values from an entity

  • Loading branch information...
burzum committed May 19, 2016
1 parent 70623fa commit 1996fe9e396ee09f6597761e2a1771d9c632ec68
Showing with 31 additions and 0 deletions.
  1. +10 −0 src/Datasource/EntityTrait.php
  2. +21 −0 tests/TestCase/ORM/EntityTest.php
@@ -315,6 +315,16 @@ public function getOriginal($property)
return $this->get($property);
}
/**
* Gets all original values of the entity.
*
* @return array
*/
public function getOriginalValues()
{
return $this->_original;
}
/**
* Returns whether this entity contains a property named $property
* that contains a non-null value.
@@ -131,6 +131,27 @@ public function testExtractOriginal()
$this->assertEquals($expected, $result);
}
/**
* Test that all original values are returned properly
*
* @return void
*/
public function testExtractOriginalValues()
{
$entity = new Entity([
'id' => 1,
'title' => 'original',
'body' => 'no',
'null' => null,
], ['markNew' => true]);
$entity->set('body', 'updated body');
$result = $entity->getOriginalValues(['id', 'title', 'body', 'null']);
$expected = [
'body' => 'no'
];
$this->assertEquals($expected, $result);
}
/**
* Tests setting a single property using a setter function
*

0 comments on commit 1996fe9

Please sign in to comment.
You can’t perform that action at this time.