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:
mark_story 2010-12-20 13:59:09 -05:00
parent d7e411650f
commit 0b90195a52
2 changed files with 33 additions and 2 deletions

View file

@ -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);
}

View file

@ -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);
}
}