From 9e0778951a45efebed0e2d3ef9eb79273fa7a799 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 24 Oct 2012 21:25:44 -0400 Subject: [PATCH] Add some fixed orders. Hopefully this makes tests in postgres more reliable. --- .../Component/PaginatorComponentTest.php | 15 ++++++++++++--- lib/Cake/Test/Case/Model/ModelReadTest.php | 8 ++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 12ede8beab6..a9f96a4cf0b 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -353,12 +353,18 @@ public function testPaginate() { $Controller->request->query = array(); $Controller->constructClasses(); - $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); - $this->assertEquals(array(1, 2, 3), $results); - + $Controller->Paginator->settings = array( + 'order' => array('PaginatorControllerComment.id' => 'ASC') + ); $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id'); $this->assertEquals(array(1, 2, 3, 4, 5, 6), $results); + $Controller->Paginator->settings = array( + 'order' => array('PaginatorControllerPost.id' => 'ASC') + ); + $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEquals(array(1, 2, 3), $results); + $Controller->modelClass = null; $Controller->uses[0] = 'Plugin.PaginatorControllerPost'; @@ -473,6 +479,9 @@ public function testPaginateExtraParams() { $Controller->constructClasses(); $Controller->request->params['named'] = array('page' => '-1', 'contain' => array('PaginatorControllerComment')); + $Controller->Paginator->settings = array( + 'order' => array('PaginatorControllerPost.id' => 'ASC') + ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index 6f14e47a208..ef6f3ad4782 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -4959,7 +4959,9 @@ public function testUnBindMultipleTimesWithDifferentResetSettings() { public function testAssociationAfterFind() { $this->loadFixtures('Post', 'Author', 'Comment'); $TestModel = new Post(); - $result = $TestModel->find('all'); + $result = $TestModel->find('all', array( + 'order' => array('Post.id' => 'ASC') + )); $expected = array( array( 'Post' => array( @@ -5384,7 +5386,9 @@ public function testNonNumericHabtmJoinKey() { )); $Post->Tag->primaryKey = 'tag'; - $result = $Post->find('all'); + $result = $Post->find('all', array( + 'order' => array('Post.id' => 'ASC') + )); $expected = array( array( 'Post' => array(