Permalink
Browse files

Fixing double merging of url options in paginator helper. This was ca…

…using duplicate passed url parameters in next()/prev().

Test cases added.
Fixes #391
  • Loading branch information...
1 parent c643890 commit efa36abdf049a57662bc3323828957de3742dfb1 @markstory markstory committed Dec 8, 2009
Showing with 22 additions and 3 deletions.
  1. +3 −3 cake/libs/view/helpers/paginator.php
  2. +19 −0 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -411,12 +411,12 @@ function __pagingLink($which, $title = null, $options = array(), $disabledTitle
${$key} = $options[$key];
unset($options[$key]);
}
- $url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
+ $urlParams = array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step));
if ($this->{$check}($model)) {
- return $this->link($title, $url, array_merge($options, array('escape' => $escape, 'class' => $class)));
+ return $this->link($title, $urlParams, array_merge($options, compact('escape', 'class', 'url')));
} else {
- return $this->Html->tag($tag, $title, array_merge($options, array('class' => $class, 'escape' => $escape)));
+ return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
}
}
@@ -745,6 +745,25 @@ function testPagingLinks() {
'/a',
);
$this->assertTags($result, $expected);
+
+ $this->Paginator->params['paging'] = array(
+ 'Client' => array(
+ 'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true,
+ 'nextPage' => false, 'pageCount' => 2,
+ 'defaults' => array(),
+ 'options' => array(
+ 'page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array()
+ )
+ )
+ );
+ $this->Paginator->options(array('url' => array(12, 'page' => 3)));
+ $result = $this->Paginator->prev('Prev', array('url' => array(12, 'foo' => 'bar')));
+ $expected = array(
+ 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'),
+ 'Prev',
+ '/a',
+ );
+ $this->assertTags($result, $expected);
}
/**

0 comments on commit efa36ab

Please sign in to comment.