mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding tests to paginate() to make sure extra parameters cannot be defined via URL
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7011 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
8f92952d46
commit
ac9a96663d
1 changed files with 25 additions and 0 deletions
|
@ -34,6 +34,11 @@ class ControllerPost extends CakeTestModel {
|
|||
var $name = 'ControllerPost';
|
||||
var $useTable = 'posts';
|
||||
var $invalidFields = array('name' => 'error_msg');
|
||||
var $lastQuery = null;
|
||||
|
||||
function beforeFind($query) {
|
||||
$this->lastQuery = $query;
|
||||
}
|
||||
}
|
||||
class ControllerComment extends CakeTestModel {
|
||||
var $name = 'ControllerComment';
|
||||
|
@ -130,7 +135,27 @@ class ControllerTest extends CakeTestCase {
|
|||
$results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1);
|
||||
$this->assertEqual($results, array(1, 2, 3));
|
||||
}
|
||||
|
||||
function testPaginateExtraParams() {
|
||||
$Controller =& new Controller();
|
||||
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
||||
$Controller->passedArgs[] = '1';
|
||||
$Controller->params['url'] = array();
|
||||
$Controller->constructClasses();
|
||||
|
||||
$Controller->passedArgs = array('page' => '-1', 'contain' => array('ControllerComment'));
|
||||
$result = $Controller->paginate('ControllerPost');
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1);
|
||||
$this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3));
|
||||
$this->assertTrue(!isset($Controller->ControllerPost->lastQuery['contain']));
|
||||
|
||||
$Controller->passedArgs = array('page' => '-1');
|
||||
$Controller->paginate = array('ControllerPost' => array('contain' => array('ControllerComment')));
|
||||
$result = $Controller->paginate('ControllerPost');
|
||||
$this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1);
|
||||
$this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3));
|
||||
$this->assertFalse(!isset($Controller->ControllerPost->lastQuery['contain']));
|
||||
}
|
||||
|
||||
function testDefaultPaginateParams() {
|
||||
|
|
Loading…
Reference in a new issue