Skip to content

Commit

Permalink
Returning all original values of an entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed May 19, 2016
1 parent 1996fe9 commit 94be119
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Datasource/EntityTrait.php
Expand Up @@ -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;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions tests/TestCase/ORM/EntityTest.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 94be119

Please sign in to comment.