mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding tests for creating next/prev links with querystrings.
Removing code that doesn't seem to do anything, no tests fail when its removed.
This commit is contained in:
parent
d7e411650f
commit
0b90195a52
2 changed files with 33 additions and 2 deletions
|
@ -357,11 +357,10 @@ class PaginatorHelper extends AppHelper {
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -2199,4 +2199,36 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue