Adding 'type' key to both sets of query calls in Controller::paginate(), fixes #5441

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7680 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-09-29 21:19:37 +00:00
parent 2cb2ca554c
commit 4b8acf4647
2 changed files with 14 additions and 2 deletions

View file

@ -985,9 +985,12 @@ class Controller extends Object {
if (isset($defaults[0])) { if (isset($defaults[0])) {
$type = array_shift($defaults); $type = array_shift($defaults);
} }
$extra = array_diff_key($defaults, compact( $extra = array_diff_assoc($defaults, compact(
'conditions', 'fields', 'order', 'limit', 'page', 'recursive' 'conditions', 'fields', 'order', 'limit', 'page', 'recursive'
)); ));
if ($type !== 'all') {
$extra['type'] = $type;
}
if (method_exists($object, 'paginateCount')) { if (method_exists($object, 'paginateCount')) {
$count = $object->paginateCount($conditions, $recursive, $extra); $count = $object->paginateCount($conditions, $recursive, $extra);

View file

@ -493,11 +493,20 @@ class ControllerTest extends CakeTestCase {
$Controller->params['url'] = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->paginate = array( $Controller->paginate = array(
'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')); 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')
);
$result = $Controller->paginate('ControllerPaginateModel'); $result = $Controller->paginate('ControllerPaginateModel');
$expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id'); $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id');
$this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected);
$this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected);
$Controller->paginate = array(
'ControllerPaginateModel' => array('foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')
);
$Controller->paginate('ControllerPaginateModel');
$expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo');
$this->assertEqual($Controller->ControllerPaginateModel->extra, $expected);
$this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected);
} }
/** /**
* testDefaultPaginateParams method * testDefaultPaginateParams method