Browse Source

Testing the important things and not specific behavior of the
database servers

Jose Lorenzo Rodriguez 11 years ago
parent
commit
8545b87df0
1 changed files with 7 additions and 6 deletions
  1. 7 6
      tests/TestCase/Database/QueryTest.php

+ 7 - 6
tests/TestCase/Database/QueryTest.php

@@ -1477,14 +1477,15 @@ class QueryTest extends TestCase
             ->select(['id', 'author_id'])
             ->distinct(['author_id'])
             ->from(['a' => 'articles'])
-            ->order(['id' => 'DESC'])
+            ->order(['id' => 'ASC'])
             ->execute();
         $this->assertCount(2, $result);
-        $expected = [
-            ['id' => 3, 'author_id' => 1],
-            ['id' => 2, 'author_id' => 3],
-        ];
-        $this->assertEquals($expected, $result->fetchAll('assoc'));
+        $results = $result->fetchAll('assoc');
+        $this->assertEquals(['id', 'author_id'], array_keys($results[0]));
+        $this->assertEquals(
+            [3, 1],
+            collection($results)->sortBy('author_id')->extract('author_id')->toList()
+        );
     }
 
     /**