From 7f64c8a88f22aa73261ae867a2fecbb9d8b2f722 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Thu, 6 Feb 2014 21:36:22 +0100 Subject: [PATCH] Improving tests --- tests/TestCase/ORM/QueryTest.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/TestCase/ORM/QueryTest.php b/tests/TestCase/ORM/QueryTest.php index 273f41072be..40638b61686 100644 --- a/tests/TestCase/ORM/QueryTest.php +++ b/tests/TestCase/ORM/QueryTest.php @@ -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); } + }