Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing next()/prev() when paginating multiple models. Added tests fro…

…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...
commit 287968934ffe26728d5ebcd98746dc5941adecd8 1 parent c53c287
@markstory markstory authored
View
2  cake/libs/view/helpers/paginator.php
@@ -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;
}
View
29 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -403,6 +403,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
*
* @access public
Please sign in to comment.
Something went wrong with that request. Please try again.