Skip to content

Commit

Permalink
Enforce specific ordering to fix failing tests.
Browse files Browse the repository at this point in the history
With the addition of foreign key constraints some ordering changes
occur, this solidifies the ordering of results.
  • Loading branch information
markstory committed Sep 6, 2014
1 parent c29bed8 commit 94f18be
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -1719,7 +1719,9 @@ public function testFormatDeepAssocationRecords() {
});
};
$query = $table->find()
->contain(['Articles' => $builder, 'Articles.Authors' => $builder]);
->contain(['Articles' => $builder, 'Articles.Authors' => $builder])
->order(['Articles.id' => 'ASC']);

$query->formatResults(function($results) {
return $results->map(function($row) {
return sprintf(
Expand Down Expand Up @@ -1799,9 +1801,11 @@ public function testContainInAssociationQuery() {
$table->belongsTo('Articles');
$table->association('Articles')->target()->belongsTo('Authors');

$query = $table->find()->contain(['Articles' => function($q) {
return $q->contain('Authors');
}]);
$query = $table->find()
->order(['Articles.id' => 'ASC'])
->contain(['Articles' => function($q) {
return $q->contain('Authors');
}]);
$results = $query->extract('article.author.name')->toArray();
$expected = ['mariano', 'mariano', 'larry', 'larry'];
$this->assertEquals($expected, $results);
Expand Down

0 comments on commit 94f18be

Please sign in to comment.