Skip to content

Commit

Permalink
Adding tests for creating next/prev links with querystrings.
Browse files Browse the repository at this point in the history
Removing code that doesn't seem to do anything, no tests fail when its removed.
  • Loading branch information
markstory committed Dec 20, 2010
1 parent d7e4116 commit 0b90195
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cake/libs/view/helpers/paginator.php
Expand Up @@ -357,11 +357,10 @@ public function link($title, $url = array(), $options = array()) {
$url = array_merge((array)$options['url'], (array)$url);
unset($options['url']);
}

$url = $this->url($url, true, $model);

$obj = isset($options['update']) ? $this->_ajaxHelperClass : 'Html';
$url = array_merge(array('page' => $this->current($model)), $url);
$url = array_merge(Set::filter($url, true), array_intersect_key($url, array('plugin' => true)));
return $this->{$obj}->link($title, $url, $options);
}

Expand Down
32 changes: 32 additions & 0 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -2199,4 +2199,36 @@ function testQuerystringUrlGeneration() {
$this->assertEquals($expected, $result);
}

/**
* test querystring paging link.
*
* @return void
*/
function testQuerystringNextAndPrev() {
$this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring';
$this->Paginator->request->params['paging']['Article']['page'] = 2;
$this->Paginator->request->params['paging']['Article']['nextPage'] = true;
$this->Paginator->request->params['paging']['Article']['prevPage'] = true;

$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/?page=3', 'class' => 'next'),
'Next',
'/a',
'/span'
);
$this->assertTags($result, $expected);

$result = $this->Paginator->prev('Prev');
$expected = array(
'<span',
'a' => array('href' => '/?page=1', 'class' => 'prev'),
'Prev',
'/a',
'/span'
);
$this->assertTags($result, $expected);
}

}

0 comments on commit 0b90195

Please sign in to comment.