Skip to content

Commit

Permalink
Fixing next()/prev() when paginating multiple models. Added tests fro…
Browse files Browse the repository at this point in the history
…m 'hummer'. Fixes #5970

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7989 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Jan 14, 2009
1 parent c53c287 commit 2879689
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/paginator.php
Expand Up @@ -304,7 +304,7 @@ function __pagingLink($which, $title = null, $options = array(), $disabledTitle
$options = array_merge($_defaults, (array)$options);
$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) {
$title = $disabledTitle;
}
Expand Down
29 changes: 29 additions & 0 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -402,6 +402,35 @@ function testPagingLinks() {
);
$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
*
Expand Down

0 comments on commit 2879689

Please sign in to comment.