mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Moving test case and adding doc block.
This commit is contained in:
parent
4ac0a55aff
commit
7467224455
1 changed files with 26 additions and 21 deletions
|
@ -706,6 +706,32 @@ class ControllerTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
@ -1281,26 +1307,5 @@ class ControllerTest extends CakeTestCase {
|
|||
$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));
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue