From 0b90195a5256118858c35369b1e2cfef75e025da Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Dec 2010 13:59:09 -0500 Subject: [PATCH] Adding tests for creating next/prev links with querystrings. Removing code that doesn't seem to do anything, no tests fail when its removed. --- cake/libs/view/helpers/paginator.php | 3 +- .../libs/view/helpers/paginator.test.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 69da3a24a17..6f714564389 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -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); } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 54602424f57..2bad399f492 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -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( + ' array('href' => '/?page=3', 'class' => 'next'), + 'Next', + '/a', + '/span' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->prev('Prev'); + $expected = array( + ' array('href' => '/?page=1', 'class' => 'prev'), + 'Prev', + '/a', + '/span' + ); + $this->assertTags($result, $expected); + } + }