Moving test case and adding doc block.

This commit is contained in:
Mark Story 2009-12-19 19:41:25 -05:00
parent 4ac0a55aff
commit 7467224455

View file

@ -706,6 +706,32 @@ class ControllerTest extends CakeTestCase {
$this->assertEqual($results, array(3, 2, 1)); $this->assertEqual($results, array(3, 2, 1));
} }
/**
* 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 * testFlash method
* *
@ -1281,26 +1307,5 @@ class ControllerTest extends CakeTestCase {
$expected = array(404 => 'Sorry Bro'); $expected = array(404 => 'Sorry Bro');
$this->assertEqual($result, $expected); $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));
}
} }
?> ?>