Fixing next()/prev() when paginating multiple models. Added tests from 'hummer'. Fixes #5970

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7989 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2009-01-14 22:08:11 +00:00
parent c53c28760f
commit 287968934f
2 changed files with 30 additions and 1 deletions

View file

@ -304,7 +304,7 @@ class PaginatorHelper extends AppHelper {
$options = array_merge($_defaults, (array)$options); $options = array_merge($_defaults, (array)$options);
$paging = $this->params($options['model']); $paging = $this->params($options['model']);
if (!$this->{$check}() && (!empty($disabledTitle) || !empty($disabledOptions))) { if (!$this->{$check}($options['model']) && (!empty($disabledTitle) || !empty($disabledOptions))) {
if (!empty($disabledTitle) && $disabledTitle !== true) { if (!empty($disabledTitle) && $disabledTitle !== true) {
$title = $disabledTitle; $title = $disabledTitle;
} }

View file

@ -402,6 +402,35 @@ class PaginatorTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* testPagingLinksNotDefaultModel
*
* Test the creation of paging links when the non default model is used.
*
* @access public
* @return void
*/
function testPagingLinksNotDefaultModel() {
// Multiple Model Paginate
$this->Paginator->params['paging'] = array(
'Client' => array(
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
'defaults' => array( 'limit'=>3, 'order' => array('Client.name' => 'DESC')),
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())
),
'Server' => array(
'page' => 1, 'current' => 1, 'count' => 5, 'prevPage' => false, 'nextPage' => false, 'pageCount' => 5,
'defaults' => array(),
'options' => array('page' => 1, 'limit' => 5, 'order' => array('Server.name' => 'ASC'), 'conditions' => array())
)
);
$result = $this->Paginator->next('Next', array('model' => 'Client'));
$this->assertPattern('/^<a[^<>]+>Next<\/a>$/', $result);
$this->assertPattern('/href="\/index\/page:2"/', $result); // These is passed.
$result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server'));
$this->assertPattern('/^<div>No Next<\/div>$/', $result);
}
/** /**
* testGenericLinks method * testGenericLinks method
* *