mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
do not display page:1 or ?page=1 to avoid duplicate content in paginator helper output
This commit is contained in:
parent
532b2099e5
commit
05415dd83f
2 changed files with 80 additions and 67 deletions
|
@ -157,7 +157,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -165,7 +165,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('date');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -173,7 +173,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title', 'TestTitle');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -181,7 +181,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'));
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -190,7 +190,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Article']['options']['sort'] = 'title';
|
||||
$result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'));
|
||||
$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',
|
||||
'/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']['sort'] = null;
|
||||
$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']['sort'] = null;
|
||||
$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']['sort'] = null;
|
||||
$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']['sort'] = null;
|
||||
$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']['sort'] = null;
|
||||
$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']['sort'] = null;
|
||||
$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']['sort'] = null;
|
||||
$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');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -254,7 +254,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('full_name');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -263,7 +263,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('full_name' => 'desc');
|
||||
$result = $this->Paginator->sort('Article.full_name');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -271,7 +271,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('full_name');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -295,7 +295,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title', 'TestTitle', array('direction' => 'desc'));
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -303,7 +303,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'), array('direction' => 'desc'));
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -326,7 +326,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$result = $this->Paginator->sort('Article.title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -335,7 +335,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$result = $this->Paginator->sort('Article.title', 'Title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -344,7 +344,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$result = $this->Paginator->sort('Article.title', 'Title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -353,7 +353,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
|
||||
$result = $this->Paginator->sort('title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -534,7 +534,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->options(array('url' => array('param')));
|
||||
$result = $this->Paginator->sort('title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -543,7 +543,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->options(array('url' => array('param')));
|
||||
$result = $this->Paginator->sort('Article.title', 'Title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -558,14 +558,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
public function testUrlGeneration() {
|
||||
$result = $this->Paginator->sort('controller');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/page:1/sort:controller/direction:asc'),
|
||||
'a' => array('href' => '/index/sort:controller/direction:asc'),
|
||||
'Controller',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->url();
|
||||
$this->assertEquals('/index/page:1', $result);
|
||||
$this->assertEquals('/', $result);
|
||||
|
||||
$this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
|
||||
$result = $this->Paginator->url();
|
||||
|
@ -627,7 +627,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('prev', array('url' => $options));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/members/posts/index/page:1', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/members/posts', 'rel' => 'prev'),
|
||||
'prev',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -724,7 +724,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title');
|
||||
$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',
|
||||
'/a'
|
||||
);
|
||||
|
@ -791,7 +791,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/articles/index/2/foo:bar?x=y&page=1&sort=title&direction=asc'),
|
||||
'a' => array('href' => '/articles/index/2/foo:bar?x=y&sort=title&direction=asc'),
|
||||
'Title',
|
||||
'/a'
|
||||
);
|
||||
|
@ -867,7 +867,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/', 'rel' => 'prev'),
|
||||
'<< Previous',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -876,7 +876,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->prev('<< Previous', array('tag' => false), null, array('class' => 'disabled'));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'prev', 'class' => 'prev'),
|
||||
'a' => array('href' => '/', 'rel' => 'prev', 'class' => 'prev'),
|
||||
'<< Previous',
|
||||
'/a'
|
||||
);
|
||||
|
@ -890,7 +890,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/', 'rel' => 'prev'),
|
||||
'<< Previous',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -928,7 +928,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/', 'rel' => 'prev'),
|
||||
'<< Previous',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -938,7 +938,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/', 'rel' => 'prev'),
|
||||
'preg:/<< Previous/',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -1042,7 +1042,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array(
|
||||
'href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC',
|
||||
'href' => '/index/limit:3/sort:Client.name/direction:DESC',
|
||||
'rel' => 'prev'
|
||||
),
|
||||
'<< Previous',
|
||||
|
@ -1084,7 +1084,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('Prev');
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/index/page:1/limit:10', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/index/limit:10', 'rel' => 'prev'),
|
||||
'Prev',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -1114,7 +1114,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar')));
|
||||
$expected = array(
|
||||
'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',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -1254,13 +1254,13 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
public function testGenericLinksWithPresetOptions() {
|
||||
$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'));
|
||||
$result = $this->Paginator->link('Foo!', array('page' => 1));
|
||||
$this->assertTags($result, array(
|
||||
'a' => array(
|
||||
'href' => '/index/page:1',
|
||||
'href' => '/',
|
||||
'sort' => 'title',
|
||||
'direction' => 'desc'
|
||||
),
|
||||
|
@ -1270,7 +1270,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$this->Paginator->options(array('sort' => null, 'direction' => null));
|
||||
$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(
|
||||
'sort' => 'title',
|
||||
|
@ -1278,7 +1278,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
)));
|
||||
$result = $this->Paginator->link('Foo!', array('page' => 1));
|
||||
$this->assertTags($result, array(
|
||||
'a' => array('href' => '/index/page:1/sort:title/direction:desc'),
|
||||
'a' => array('href' => '/index/sort:title/direction:desc'),
|
||||
'Foo!',
|
||||
'/a'
|
||||
));
|
||||
|
@ -1364,7 +1364,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(true);
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1477,7 +1477,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link'));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1499,7 +1499,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active'));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1521,7 +1521,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'a'));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1543,7 +1543,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1565,7 +1565,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('last' => 1));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1602,7 +1602,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1642,7 +1642,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1683,7 +1683,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1724,7 +1724,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1800,7 +1800,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$result = $this->Paginator->numbers(array('class' => 'page-link'));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1827,7 +1827,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
|
||||
$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',
|
||||
'...',
|
||||
|
@ -1845,7 +1845,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
|
||||
$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',
|
||||
' | ',
|
||||
|
@ -1861,7 +1861,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - '));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -1877,7 +1877,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - '));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -1904,7 +1904,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Client']['page'] = 4893;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -1933,7 +1933,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Client']['page'] = 58;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -1968,7 +1968,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Client']['page'] = 5;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -1997,7 +1997,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->request->params['paging']['Client']['page'] = 3;
|
||||
$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => ' ~~~ '));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -2014,7 +2014,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$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>'));
|
||||
$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',
|
||||
' - ',
|
||||
|
@ -2038,7 +2038,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->first('<<', array('tag' => 'li', 'class' => 'first'));
|
||||
$expected = array(
|
||||
'li' => array('class' => 'first'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'first'),
|
||||
'a' => array('href' => '/', 'rel' => 'first'),
|
||||
'<<',
|
||||
'/a',
|
||||
'/li'
|
||||
|
@ -2100,7 +2100,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$expected = array(
|
||||
'<span',
|
||||
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'
|
||||
)),
|
||||
'<< first',
|
||||
'/a',
|
||||
|
@ -2118,7 +2118,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->first();
|
||||
$expected = array(
|
||||
'<span',
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'first'),
|
||||
'a' => array('href' => '/', 'rel' => 'first'),
|
||||
'<< first',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -2128,7 +2128,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->first(2);
|
||||
$expected = array(
|
||||
'<span',
|
||||
array('a' => array('href' => '/index/page:1')), '1', '/a',
|
||||
array('a' => array('href' => '/')), '1', '/a',
|
||||
'/span',
|
||||
' | ',
|
||||
'<span',
|
||||
|
@ -2506,6 +2506,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*/
|
||||
public function testQuerystringUrlGeneration() {
|
||||
$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'));
|
||||
$expected = '/?page=4';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -2539,7 +2547,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->prev('Prev');
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'a' => array('href' => '/?page=1', 'rel' => 'prev'),
|
||||
'a' => array('href' => '/', 'rel' => 'prev'),
|
||||
'Prev',
|
||||
'/a',
|
||||
'/span'
|
||||
|
|
|
@ -427,7 +427,12 @@ class PaginatorHelper extends AppHelper {
|
|||
$url = array_merge($url, compact('sort', 'direction'));
|
||||
}
|
||||
$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) {
|
||||
return $url;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue