Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add getDirty method
  • Loading branch information
Michael Hoffmann committed Mar 6, 2017
1 parent 607c15c commit eca8e6b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Datasource/EntityTrait.php
Expand Up @@ -776,6 +776,16 @@ public function isDirty($property = null)
return isset($this->_dirty[$property]);
}

/**
* Gets the dirty properties.
*
* @return array
*/
public function getDirty()
{
return array_keys($this->_dirty);
}

/**
* Sets the entire entity as clean, which means that it will appear as
* no properties being modified or added at all. This is an useful call
Expand Down
22 changes: 22 additions & 0 deletions tests/TestCase/ORM/EntityTest.php
Expand Up @@ -839,6 +839,28 @@ public function testExtractDirty()
$this->assertEquals($expected, $result);
}

/**
* Tests the getDirty method
*
* @return void
*/
public function testGetDirty()
{
$entity = new Entity([
'id' => 1,
'title' => 'Foo',
'author_id' => 3
]);

$expected = [
'id',
'title',
'author_id'
];
$result = $entity->getDirty();
$this->assertSame($expected, $entity->getDirty());
}

/**
* Tests the clean method
*
Expand Down

0 comments on commit eca8e6b

Please sign in to comment.