Merge pull request #1427 from dereuromark/2.4-paginator-page1

fixes #700
This commit is contained in:
Christian Winther 2013-07-17 09:26:08 -07:00
commit 4416f2e796
2 changed files with 80 additions and 67 deletions

View file

@ -157,7 +157,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), 'a' => array('href' => '/officespace/accounts/index/param/sort:title/direction:asc'),
'Title', 'Title',
'/a' '/a'
); );
@ -165,7 +165,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('date'); $result = $this->Paginator->sort('date');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:date/direction:desc', 'class' => 'asc'), 'a' => array('href' => '/officespace/accounts/index/param/sort:date/direction:desc', 'class' => 'asc'),
'Date', 'Date',
'/a' '/a'
); );
@ -173,7 +173,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title', 'TestTitle'); $result = $this->Paginator->sort('title', 'TestTitle');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), 'a' => array('href' => '/officespace/accounts/index/param/sort:title/direction:asc'),
'TestTitle', 'TestTitle',
'/a' '/a'
); );
@ -181,7 +181,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending')); $result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'));
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), 'a' => array('href' => '/officespace/accounts/index/param/sort:title/direction:asc'),
'ascending', 'ascending',
'/a' '/a'
); );
@ -190,7 +190,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['sort'] = 'title'; $this->Paginator->request->params['paging']['Article']['options']['sort'] = 'title';
$result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending')); $result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'));
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc', 'class' => 'asc'), 'a' => array('href' => '/officespace/accounts/index/param/sort:title/direction:desc', 'class' => 'asc'),
'descending', 'descending',
'/a' '/a'
); );
@ -199,37 +199,37 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc')); $result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc')); $result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc')); $result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc')); $result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null; $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc', 'class' => 'foo')); $result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc', 'class' => 'foo'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="foo asc">Title<\/a>$/', $result); $this->assertRegExp('/\/accounts\/index\/param\/sort:title\/direction:desc" class="foo asc">Title<\/a>$/', $result);
} }
/** /**
@ -246,7 +246,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('Article.full_name'); $result = $this->Paginator->sort('Article.full_name');
$expected = array( $expected = array(
'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:desc', 'class' => 'asc'), 'a' => array('href' => '/accounts/index/sort:Article.full_name/direction:desc', 'class' => 'asc'),
'Article Full Name', 'Article Full Name',
'/a' '/a'
); );
@ -254,7 +254,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('full_name'); $result = $this->Paginator->sort('full_name');
$expected = array( $expected = array(
'a' => array('href' => '/accounts/index/page:1/sort:full_name/direction:desc', 'class' => 'asc'), 'a' => array('href' => '/accounts/index/sort:full_name/direction:desc', 'class' => 'asc'),
'Full Name', 'Full Name',
'/a' '/a'
); );
@ -263,7 +263,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('full_name' => 'desc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('full_name' => 'desc');
$result = $this->Paginator->sort('Article.full_name'); $result = $this->Paginator->sort('Article.full_name');
$expected = array( $expected = array(
'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:asc', 'class' => 'desc'), 'a' => array('href' => '/accounts/index/sort:Article.full_name/direction:asc', 'class' => 'desc'),
'Article Full Name', 'Article Full Name',
'/a' '/a'
); );
@ -271,7 +271,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('full_name'); $result = $this->Paginator->sort('full_name');
$expected = array( $expected = array(
'a' => array('href' => '/accounts/index/page:1/sort:full_name/direction:asc', 'class' => 'desc'), 'a' => array('href' => '/accounts/index/sort:full_name/direction:asc', 'class' => 'desc'),
'Full Name', 'Full Name',
'/a' '/a'
); );
@ -295,7 +295,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title', 'TestTitle', array('direction' => 'desc')); $result = $this->Paginator->sort('title', 'TestTitle', array('direction' => 'desc'));
$expected = array( $expected = array(
'a' => array('href' => '/accounts/index/param/page:1/sort:title/direction:desc'), 'a' => array('href' => '/accounts/index/param/sort:title/direction:desc'),
'TestTitle', 'TestTitle',
'/a' '/a'
); );
@ -303,7 +303,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'), array('direction' => 'desc')); $result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'), array('direction' => 'desc'));
$expected = array( $expected = array(
'a' => array('href' => '/accounts/index/param/page:1/sort:title/direction:desc'), 'a' => array('href' => '/accounts/index/param/sort:title/direction:desc'),
'descending', 'descending',
'/a' '/a'
); );
@ -326,7 +326,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
$result = $this->Paginator->sort('Article.title'); $result = $this->Paginator->sort('Article.title');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'), 'a' => array('href' => '/officespace/accounts/index/sort:Article.title/direction:asc', 'class' => 'desc'),
'Article Title', 'Article Title',
'/a' '/a'
); );
@ -335,7 +335,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
$result = $this->Paginator->sort('Article.title', 'Title'); $result = $this->Paginator->sort('Article.title', 'Title');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'), 'a' => array('href' => '/officespace/accounts/index/sort:Article.title/direction:asc', 'class' => 'desc'),
'Title', 'Title',
'/a' '/a'
); );
@ -344,7 +344,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$result = $this->Paginator->sort('Article.title', 'Title'); $result = $this->Paginator->sort('Article.title', 'Title');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc', 'class' => 'asc'), 'a' => array('href' => '/officespace/accounts/index/sort:Article.title/direction:desc', 'class' => 'asc'),
'Title', 'Title',
'/a' '/a'
); );
@ -353,7 +353,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc'); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$expected = array( $expected = array(
'a' => array('href' => '/officespace/accounts/index/page:1/sort:title/direction:asc'), 'a' => array('href' => '/officespace/accounts/index/sort:title/direction:asc'),
'Title', 'Title',
'/a' '/a'
); );
@ -534,7 +534,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->options(array('url' => array('param'))); $this->Paginator->options(array('url' => array('param')));
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$expected = array( $expected = array(
'a' => array('href' => '/admin/test/index/param/page:1/sort:title/direction:asc'), 'a' => array('href' => '/admin/test/index/param/sort:title/direction:asc'),
'Title', 'Title',
'/a' '/a'
); );
@ -543,7 +543,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->options(array('url' => array('param'))); $this->Paginator->options(array('url' => array('param')));
$result = $this->Paginator->sort('Article.title', 'Title'); $result = $this->Paginator->sort('Article.title', 'Title');
$expected = array( $expected = array(
'a' => array('href' => '/admin/test/index/param/page:1/sort:Article.title/direction:asc'), 'a' => array('href' => '/admin/test/index/param/sort:Article.title/direction:asc'),
'Title', 'Title',
'/a' '/a'
); );
@ -558,14 +558,14 @@ class PaginatorHelperTest extends CakeTestCase {
public function testUrlGeneration() { public function testUrlGeneration() {
$result = $this->Paginator->sort('controller'); $result = $this->Paginator->sort('controller');
$expected = array( $expected = array(
'a' => array('href' => '/index/page:1/sort:controller/direction:asc'), 'a' => array('href' => '/index/sort:controller/direction:asc'),
'Controller', 'Controller',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Paginator->url(); $result = $this->Paginator->url();
$this->assertEquals('/index/page:1', $result); $this->assertEquals('/', $result);
$this->Paginator->request->params['paging']['Article']['options']['page'] = 2; $this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
$result = $this->Paginator->url(); $result = $this->Paginator->url();
@ -627,7 +627,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('prev', array('url' => $options)); $result = $this->Paginator->prev('prev', array('url' => $options));
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/members/posts/index/page:1', 'rel' => 'prev'), 'a' => array('href' => '/members/posts', 'rel' => 'prev'),
'prev', 'prev',
'/a', '/a',
'/span' '/span'
@ -724,7 +724,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$expected = array( $expected = array(
'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc?x=y'), 'a' => array('href' => '/articles/index/2/foo:bar/sort:title/direction:asc?x=y'),
'Title', 'Title',
'/a' '/a'
); );
@ -791,7 +791,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title'); $result = $this->Paginator->sort('title');
$expected = array( $expected = array(
'a' => array('href' => '/articles/index/2/foo:bar?x=y&amp;page=1&amp;sort=title&amp;direction=asc'), 'a' => array('href' => '/articles/index/2/foo:bar?x=y&amp;sort=title&amp;direction=asc'),
'Title', 'Title',
'/a' '/a'
); );
@ -867,7 +867,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/index/page:1', 'rel' => 'prev'), 'a' => array('href' => '/', 'rel' => 'prev'),
'&lt;&lt; Previous', '&lt;&lt; Previous',
'/a', '/a',
'/span' '/span'
@ -876,7 +876,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('<< Previous', array('tag' => false), null, array('class' => 'disabled')); $result = $this->Paginator->prev('<< Previous', array('tag' => false), null, array('class' => 'disabled'));
$expected = array( $expected = array(
'a' => array('href' => '/index/page:1', 'rel' => 'prev', 'class' => 'prev'), 'a' => array('href' => '/', 'rel' => 'prev', 'class' => 'prev'),
'&lt;&lt; Previous', '&lt;&lt; Previous',
'/a' '/a'
); );
@ -890,7 +890,7 @@ class PaginatorHelperTest extends CakeTestCase {
); );
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/index/page:1', 'rel' => 'prev'), 'a' => array('href' => '/', 'rel' => 'prev'),
'&lt;&lt; Previous', '&lt;&lt; Previous',
'/a', '/a',
'/span' '/span'
@ -928,7 +928,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('<< Previous', array('escape' => true)); $result = $this->Paginator->prev('<< Previous', array('escape' => true));
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/index/page:1', 'rel' => 'prev'), 'a' => array('href' => '/', 'rel' => 'prev'),
'&lt;&lt; Previous', '&lt;&lt; Previous',
'/a', '/a',
'/span' '/span'
@ -938,7 +938,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('<< Previous', array('escape' => false)); $result = $this->Paginator->prev('<< Previous', array('escape' => false));
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/index/page:1', 'rel' => 'prev'), 'a' => array('href' => '/', 'rel' => 'prev'),
'preg:/<< Previous/', 'preg:/<< Previous/',
'/a', '/a',
'/span' '/span'
@ -1042,7 +1042,7 @@ class PaginatorHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array( 'a' => array(
'href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'href' => '/index/limit:3/sort:Client.name/direction:DESC',
'rel' => 'prev' 'rel' => 'prev'
), ),
'&lt;&lt; Previous', '&lt;&lt; Previous',
@ -1084,7 +1084,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('Prev'); $result = $this->Paginator->prev('Prev');
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/index/page:1/limit:10', 'rel' => 'prev'), 'a' => array('href' => '/index/limit:10', 'rel' => 'prev'),
'Prev', 'Prev',
'/a', '/a',
'/span' '/span'
@ -1114,7 +1114,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar')));
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'rel' => 'prev'), 'a' => array('href' => '/index/12/limit:10/foo:bar', 'rel' => 'prev'),
'Prev', 'Prev',
'/a', '/a',
'/span' '/span'
@ -1254,13 +1254,13 @@ class PaginatorHelperTest extends CakeTestCase {
*/ */
public function testGenericLinksWithPresetOptions() { public function testGenericLinksWithPresetOptions() {
$result = $this->Paginator->link('Foo!', array('page' => 1)); $result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a')); $this->assertTags($result, array('a' => array('href' => '/'), 'Foo!', '/a'));
$this->Paginator->options(array('sort' => 'title', 'direction' => 'desc')); $this->Paginator->options(array('sort' => 'title', 'direction' => 'desc'));
$result = $this->Paginator->link('Foo!', array('page' => 1)); $result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array( $this->assertTags($result, array(
'a' => array( 'a' => array(
'href' => '/index/page:1', 'href' => '/',
'sort' => 'title', 'sort' => 'title',
'direction' => 'desc' 'direction' => 'desc'
), ),
@ -1270,7 +1270,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->options(array('sort' => null, 'direction' => null)); $this->Paginator->options(array('sort' => null, 'direction' => null));
$result = $this->Paginator->link('Foo!', array('page' => 1)); $result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a')); $this->assertTags($result, array('a' => array('href' => '/'), 'Foo!', '/a'));
$this->Paginator->options(array('url' => array( $this->Paginator->options(array('url' => array(
'sort' => 'title', 'sort' => 'title',
@ -1278,7 +1278,7 @@ class PaginatorHelperTest extends CakeTestCase {
))); )));
$result = $this->Paginator->link('Foo!', array('page' => 1)); $result = $this->Paginator->link('Foo!', array('page' => 1));
$this->assertTags($result, array( $this->assertTags($result, array(
'a' => array('href' => '/index/page:1/sort:title/direction:desc'), 'a' => array('href' => '/index/sort:title/direction:desc'),
'Foo!', 'Foo!',
'/a' '/a'
)); ));
@ -1364,7 +1364,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(true); $result = $this->Paginator->numbers(true);
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1', 'rel' => 'first')), 'first', '/a', '/span', array('span' => array()), array('a' => array('href' => '/', 'rel' => 'first')), 'first', '/a', '/span',
' | ', ' | ',
array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
' | ', ' | ',
@ -1477,7 +1477,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link')); $result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link'));
$expected = array( $expected = array(
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array('class' => 'page-link')), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array('class' => 'current page-link')), '2', '/span', array('span' => array('class' => 'current page-link')), '2', '/span',
' | ', ' | ',
@ -1499,7 +1499,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active')); $result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active'));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array('class' => 'active')), '2', '/span', array('span' => array('class' => 'active')), '2', '/span',
' | ', ' | ',
@ -1521,7 +1521,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'a')); $result = $this->Paginator->numbers(array('first' => 1, 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'a'));
$expected = array( $expected = array(
array('li' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/li', array('li' => array()), array('a' => array('href' => '/')), '1', '/a', '/li',
' | ', ' | ',
array('li' => array('class' => 'active')), array('a' => array()), '2', '/a', '/li', array('li' => array('class' => 'active')), array('a' => array()), '2', '/a', '/li',
' | ', ' | ',
@ -1543,7 +1543,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active')); $result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
$expected = array( $expected = array(
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array('class' => 'page-link')), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array('class' => 'active page-link')), '2', '/span', array('span' => array('class' => 'active page-link')), '2', '/span',
' | ', ' | ',
@ -1565,7 +1565,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('last' => 1)); $result = $this->Paginator->numbers(array('last' => 1));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array('class' => 'current')), '2', '/span', array('span' => array('class' => 'current')), '2', '/span',
' | ', ' | ',
@ -1602,7 +1602,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1)); $result = $this->Paginator->numbers(array('first' => 1));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
'...', '...',
array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
' | ', ' | ',
@ -1642,7 +1642,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
'...', '...',
array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
' | ', ' | ',
@ -1683,7 +1683,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' | ', ' | ',
@ -1724,7 +1724,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
'...', '...',
array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span',
' | ', ' | ',
@ -1800,7 +1800,7 @@ class PaginatorHelperTest extends CakeTestCase {
); );
$result = $this->Paginator->numbers(array('class' => 'page-link')); $result = $this->Paginator->numbers(array('class' => 'page-link'));
$expected = array( $expected = array(
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span', array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/sort:Client.name/direction:DESC')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array('class' => 'current page-link')), '2', '/span', array('span' => array('class' => 'current page-link')), '2', '/span',
' | ', ' | ',
@ -1827,7 +1827,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
'...', '...',
@ -1845,7 +1845,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' | ', ' | ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' | ', ' | ',
@ -1861,7 +1861,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ')); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - '));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -1877,7 +1877,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - ')); $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - '));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -1904,7 +1904,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Client']['page'] = 4893; $this->Paginator->request->params['paging']['Client']['page'] = 4893;
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -1933,7 +1933,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Client']['page'] = 58; $this->Paginator->request->params['paging']['Client']['page'] = 58;
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -1968,7 +1968,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Client']['page'] = 5; $this->Paginator->request->params['paging']['Client']['page'] = 5;
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - ')); $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -1997,7 +1997,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Client']['page'] = 3; $this->Paginator->request->params['paging']['Client']['page'] = 3;
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => ' ~~~ ')); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => ' ~~~ '));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -2014,7 +2014,7 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->request->params['paging']['Client']['page'] = 3; $this->Paginator->request->params['paging']['Client']['page'] = 3;
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => '<span class="ellipsis">...</span>')); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => '<span class="ellipsis">...</span>'));
$expected = array( $expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span', array('span' => array()), array('a' => array('href' => '/')), '1', '/a', '/span',
' - ', ' - ',
array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span', array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
' - ', ' - ',
@ -2038,7 +2038,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->first('<<', array('tag' => 'li', 'class' => 'first')); $result = $this->Paginator->first('<<', array('tag' => 'li', 'class' => 'first'));
$expected = array( $expected = array(
'li' => array('class' => 'first'), 'li' => array('class' => 'first'),
'a' => array('href' => '/index/page:1', 'rel' => 'first'), 'a' => array('href' => '/', 'rel' => 'first'),
'&lt;&lt;', '&lt;&lt;',
'/a', '/a',
'/li' '/li'
@ -2100,7 +2100,7 @@ class PaginatorHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'<span', '<span',
array('a' => array( array('a' => array(
'href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC', 'rel' => 'first' 'href' => FULL_BASE_URL . '/index/sort:Article.title/direction:DESC', 'rel' => 'first'
)), )),
'&lt;&lt; first', '&lt;&lt; first',
'/a', '/a',
@ -2118,7 +2118,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->first(); $result = $this->Paginator->first();
$expected = array( $expected = array(
'<span', '<span',
'a' => array('href' => '/index/page:1', 'rel' => 'first'), 'a' => array('href' => '/', 'rel' => 'first'),
'&lt;&lt; first', '&lt;&lt; first',
'/a', '/a',
'/span' '/span'
@ -2128,7 +2128,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->first(2); $result = $this->Paginator->first(2);
$expected = array( $expected = array(
'<span', '<span',
array('a' => array('href' => '/index/page:1')), '1', '/a', array('a' => array('href' => '/')), '1', '/a',
'/span', '/span',
' | ', ' | ',
'<span', '<span',
@ -2506,6 +2506,14 @@ class PaginatorHelperTest extends CakeTestCase {
*/ */
public function testQuerystringUrlGeneration() { public function testQuerystringUrlGeneration() {
$this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring'; $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring';
$result = $this->Paginator->url(array('page' => '1'));
$expected = '/';
$this->assertEquals($expected, $result);
$result = $this->Paginator->url(array('page' => '1', 'limit' => 10, 'something' => 'else'));
$expected = '/index/something:else?limit=10';
$this->assertEquals($expected, $result);
$result = $this->Paginator->url(array('page' => '4')); $result = $this->Paginator->url(array('page' => '4'));
$expected = '/?page=4'; $expected = '/?page=4';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -2539,7 +2547,7 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->prev('Prev'); $result = $this->Paginator->prev('Prev');
$expected = array( $expected = array(
'span' => array('class' => 'prev'), 'span' => array('class' => 'prev'),
'a' => array('href' => '/?page=1', 'rel' => 'prev'), 'a' => array('href' => '/', 'rel' => 'prev'),
'Prev', 'Prev',
'/a', '/a',
'/span' '/span'

View file

@ -427,7 +427,12 @@ class PaginatorHelper extends AppHelper {
$url = array_merge($url, compact('sort', 'direction')); $url = array_merge($url, compact('sort', 'direction'));
} }
$url = $this->_convertUrlKeys($url, $paging['paramType']); $url = $this->_convertUrlKeys($url, $paging['paramType']);
if (!empty($url['page']) && $url['page'] == 1) {
unset($url['page']);
}
if (!empty($url['?']['page']) && $url['?']['page'] == 1) {
unset($url['?']['page']);
}
if ($asArray) { if ($asArray) {
return $url; return $url;
} }