Skip to content
Permalink
Browse files

Returning all original values of an entity

  • Loading branch information...
burzum committed May 19, 2016
1 parent 1996fe9 commit 94be1194a90110363d79a7a693639c2b96c3211b
Showing with 13 additions and 3 deletions.
  1. +8 −1 src/Datasource/EntityTrait.php
  2. +5 −2 tests/TestCase/ORM/EntityTest.php
@@ -322,7 +322,14 @@ public function getOriginal($property)
*/
public function getOriginalValues()
{
return $this->_original;
$originals = $this->_original;
$originalKeys = array_keys($originals);
foreach ($this->_properties as $key => $value) {
if (!in_array($key, $originalKeys)) {
$originals[$key] = $value;
}
}
return $originals;
}
/**
@@ -145,9 +145,12 @@ public function testExtractOriginalValues()
'null' => null,
], ['markNew' => true]);
$entity->set('body', 'updated body');
$result = $entity->getOriginalValues(['id', 'title', 'body', 'null']);
$result = $entity->getOriginalValues();
$expected = [
'body' => 'no'
'id' => 1,
'title' => 'original',
'body' => 'no',
'null' => null,
];
$this->assertEquals($expected, $result);
}

0 comments on commit 94be119

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