Permalink
Browse files

Moving test case and adding doc block.

  • Loading branch information...
1 parent 4ac0a55 commit 74672244555f8450925bc9761d718320407deb10 @markstory markstory committed Dec 20, 2009
Showing with 26 additions and 21 deletions.
  1. +26 −21 cake/tests/cases/libs/controller/controller.test.php
@@ -707,6 +707,32 @@ function testDefaultPaginateParams() {
}
/**
+ * test paginate() and virtualField interactions
+ *
+ * @return void
+ */
+ function testPaginateOrderVirtualField() {
+ $Controller =& new Controller();
+ $Controller->uses = array('ControllerPost', 'ControllerComment');
+ $Controller->params['url'] = array();
+ $Controller->constructClasses();
+ $Controller->ControllerPost->virtualFields = array(
+ 'offset_test' => 'ControllerPost.id + 1'
+ );
+
+ $Controller->paginate = array(
+ 'fields' => array('id', 'title', 'offset_test'),
+ 'order' => array('offset_test' => 'DESC')
+ );
+ $result = $Controller->paginate('ControllerPost');
+ $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4, 3, 2));
+
+ $Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc');
+ $result = $Controller->paginate('ControllerPost');
+ $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4));
+ }
+
+/**
* testFlash method
*
* @access public
@@ -1281,26 +1307,5 @@ function testControllerHttpCodes() {
$expected = array(404 => 'Sorry Bro');
$this->assertEqual($result, $expected);
}
-
- function testPaginateOrderVirtualField() {
- $Controller =& new Controller();
- $Controller->uses = array('ControllerPost', 'ControllerComment');
- $Controller->params['url'] = array();
- $Controller->constructClasses();
- $Controller->ControllerPost->virtualFields = array(
- 'offset_test' => 'ControllerPost.id + 1'
- );
-
- $Controller->paginate = array(
- 'fields' => array('id', 'title', 'offset_test'),
- 'order' => array('offset_test' => 'DESC')
- );
- $result = $Controller->paginate('ControllerPost');
- $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4, 3, 2));
-
- $Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc');
- $result = $Controller->paginate('ControllerPost');
- $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4));
- }
}
?>

0 comments on commit 7467224

Please sign in to comment.