Skip to content
Permalink
Browse files

Marking entities as already persisted when they are fetched from the

database
  • Loading branch information...
lorenzo committed Oct 26, 2013
1 parent 28ce867 commit 95fa5efd78ae83f9c3ef283e95a2cc5b4de95243
Showing with 21 additions and 1 deletion.
  1. +1 −1 Cake/ORM/ResultSet.php
  2. +20 −0 Cake/Test/TestCase/ORM/TableTest.php
@@ -265,7 +265,7 @@ protected function _groupResult($row) {
$results[$defaultAlias]
);
$options = ['useSetters' => false, 'markClean' => true];
$options = ['useSetters' => false, 'markClean' => true, 'markNew' => false];
foreach (array_reverse($this->_associationMap) as $alias => $assoc) {
if (!isset($results[$alias])) {
continue;
@@ -917,6 +917,26 @@ public function testFindCleanEntities() {
}
}
/**
* Tests that recently fetched entities are marked as not new
*
* @return void
*/
public function testFindPersistedEntities() {
$table = new \TestApp\Model\Repository\ArticleTable([
'connection' => $this->connection,
]);
$results = $table->find('all')->contain(['tag', 'author'])->toArray();
$this->assertCount(3, $results);
foreach ($results as $article) {
$this->assertFalse($article->isNew());
foreach ((array)$article->tag as $tag) {
$this->assertFalse($tag->isNew());
$this->assertFalse($tag->extraInfo->isNew());
}
}
}
/**
* Tests that it is possible to insert a new row using the save method
*

0 comments on commit 95fa5ef

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