Browse Source

Enforce specific ordering to fix failing tests.

With the addition of foreign key constraints some ordering changes
occur, this solidifies the ordering of results.
mark_story 11 years ago
parent
commit
94f18be055
1 changed files with 8 additions and 4 deletions
  1. 8 4
      tests/TestCase/ORM/QueryTest.php

+ 8 - 4
tests/TestCase/ORM/QueryTest.php

@@ -1719,7 +1719,9 @@ class QueryTest extends TestCase {
 				});
 		};
 		$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(
@@ -1799,9 +1801,11 @@ class QueryTest extends TestCase {
 		$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);