Skip to content

Commit

Permalink
Improving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 9, 2014
1 parent 8ff4eae commit 7f64c8a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -1592,20 +1592,28 @@ public function testFormatBelongsToRecords() {

$query = $table->find()
->contain(['authors' => function($q) {
return $q->formatResults(function($authors) {
return $authors->map(function($author) {
$author->idCopy = $author->id;
return $author;
return $q
->formatResults(function($authors) {
return $authors->map(function($author) {
$author->idCopy = $author->id;
return $author;
});
})
->formatResults(function($authors) {
return $authors->map(function($author) {
$author->idCopy = $author->idCopy + 2;
return $author;
});
});
});
}]);

$query->formatResults(function($results) {
return $results->combine('id', 'author.idCopy');
});
$results = $query->toArray();
$expected = [1 => 1, 2 => 3, 3 => 1];
$expected = [1 => 3, 2 => 5, 3 => 3];
$this->assertEquals($expected, $results);
}


}

0 comments on commit 7f64c8a

Please sign in to comment.