Permalink
Browse files

For paging links the 'class' attribute is now always applied to the w…

…rapping tag for consistency. Closes #1759
  • Loading branch information...
1 parent b781762 commit 5d7929936264034316d4ccd50a0fccb5fe0cf5e9 @ADmad ADmad committed Aug 13, 2011
Showing with 74 additions and 68 deletions.
  1. +43 −47 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
  2. +31 −21 lib/Cake/View/Helper/PaginatorHelper.php
@@ -463,8 +463,8 @@ public function testSortAdminLinks() {
$this->Paginator->request->params['paging']['Article']['page'] = 1;
$result = $this->Paginator->next('Next');
$expected = array(
- '<span',
- 'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/admin/users/index/page:2', 'rel' => 'next'),
'Next',
'/a',
'/span'
@@ -566,8 +566,8 @@ public function testUrlGenerationWithPrefixes() {
$result = $this->Paginator->next('next', array('url' => $options));
$expected = array(
- '<span',
- 'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/members/posts/index/page:3', 'rel' => 'next'),
'next',
'/a',
'/span'
@@ -576,8 +576,8 @@ public function testUrlGenerationWithPrefixes() {
$result = $this->Paginator->prev('prev', array('url' => $options));
$expected = array(
- '<span',
- 'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/members/posts/index/page:1', 'rel' => 'prev'),
'prev',
'/a',
'/span'
@@ -703,8 +703,8 @@ public function testPassedArgsMergingWithUrlOptions() {
$result = $this->Paginator->next('Next');
$expected = array(
- '<span',
- 'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'rel' => 'next'),
'Next',
'/a',
'/span'
@@ -753,8 +753,8 @@ public function testPagingLinks() {
$this->Paginator->request->params['paging']['Client']['prevPage'] = true;
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
'&lt;&lt; Previous',
'/a',
'/span'
@@ -763,8 +763,8 @@ public function testPagingLinks() {
$result = $this->Paginator->next('Next');
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/index/page:3', 'rel' => 'next'),
'Next',
'/a',
'/span'
@@ -773,8 +773,8 @@ public function testPagingLinks() {
$result = $this->Paginator->next('Next', array('tag' => 'li'));
$expected = array(
- '<li',
- 'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'),
+ 'li' => array('class' => 'next'),
+ 'a' => array('href' => '/index/page:3', 'rel' => 'next'),
'Next',
'/a',
'/li'
@@ -783,8 +783,8 @@ public function testPagingLinks() {
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
'&lt;&lt; Previous',
'/a',
'/span'
@@ -793,8 +793,8 @@ public function testPagingLinks() {
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
'preg:/<< Previous/',
'/a',
'/span'
@@ -861,10 +861,9 @@ public function testPagingLinks() {
$this->Paginator->request->params['paging']['Client']['prevPage'] = true;
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array(
- '<span',
+ 'span' => array('class' => 'prev'),
'a' => array(
'href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC',
- 'class' => 'prev',
'rel' => 'prev'
),
'&lt;&lt; Previous',
@@ -875,10 +874,9 @@ public function testPagingLinks() {
$result = $this->Paginator->next('Next');
$expected = array(
- '<span',
+ 'span' => array('class' => 'next'),
'a' => array(
'href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC',
- 'class' => 'next',
'rel' => 'next'
),
'Next',
@@ -906,8 +904,8 @@ public function testPagingLinks() {
);
$result = $this->Paginator->prev('Prev');
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/index/page:1/limit:10', 'rel' => 'prev'),
'Prev',
'/a',
'/span'
@@ -928,8 +926,8 @@ public function testPagingLinks() {
$this->Paginator->options(array('url' => array(12, 'page' => 3)));
$result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar')));
$expected = array(
- '<span',
- 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'rel' => 'prev'),
'Prev',
'/a',
'/span'
@@ -968,8 +966,8 @@ public function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
$result = $this->Paginator->next('Next >>', array('escape' => false));
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/index/page:2', 'rel' => 'next'),
'preg:/Next >>/',
'/a',
'/span'
@@ -1015,8 +1013,8 @@ public function testPagingLinksNotDefaultModel() {
);
$result = $this->Paginator->next('Next', array('model' => 'Client'));
$expected = array(
- '<span',
- 'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/index/page:2', 'rel' => 'next'),
'Next',
'/a',
'/span'
@@ -1542,15 +1540,15 @@ public function testNumbers() {
'paramType' => 'named'
)
);
- $result = $this->Paginator->numbers();
+ $result = $this->Paginator->numbers(array('class' => 'page-link'));
$expected = array(
- array('span' => array()), 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/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span',
' | ',
- array('span' => array('class' => 'current')), '2', '/span',
+ array('span' => array('class' => 'current page-link')), '2', '/span',
' | ',
- array('span' => array()), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span',
' | ',
- array('span' => array()), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span',
);
$this->assertTags($result, $expected);
@@ -1780,25 +1778,24 @@ public function testNumbers() {
* @return void
*/
public function testFirstAndLastTag() {
- $result = $this->Paginator->first('<<', array('tag' => 'li'));
+ $result = $this->Paginator->first('<<', array('tag' => 'li', 'class' => 'first'));
$expected = array(
- '<li',
+ 'li' => array('class' => 'first'),
'a' => array('href' => '/index/page:1', 'rel' => 'first'),
'&lt;&lt;',
'/a',
'/li'
);
$this->assertTags($result, $expected);
- $result = $this->Paginator->last(2, array('tag' => 'li'));
-
+ $result = $this->Paginator->last(2, array('tag' => 'li', 'class' => 'last'));
$expected = array(
'...',
- '<li',
+ 'li' => array('class' => 'last'),
array('a' => array('href' => '/index/page:6')), '6', '/a',
'/li',
' | ',
- '<li',
+ array('li' => array('class' => 'last')),
array('a' => array('href' => '/index/page:7')), '7', '/a',
'/li',
);
@@ -2157,10 +2154,9 @@ public function testNextLinkUsingDotNotation() {
$result = $this->Paginator->next('Next');
$expected = array(
- '<span',
+ 'span' => array('class' => 'next'),
'a' => array(
'href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc',
- 'class' => 'next',
'rel' => 'next'
),
'Next',
@@ -2255,8 +2251,8 @@ public function testQuerystringNextAndPrev() {
$result = $this->Paginator->next('Next');
$expected = array(
- '<span',
- 'a' => array('href' => '/?page=3', 'class' => 'next', 'rel' => 'next'),
+ 'span' => array('class' => 'next'),
+ 'a' => array('href' => '/?page=3', 'rel' => 'next'),
'Next',
'/a',
'/span'
@@ -2265,8 +2261,8 @@ public function testQuerystringNextAndPrev() {
$result = $this->Paginator->prev('Prev');
$expected = array(
- '<span',
- 'a' => array('href' => '/?page=1', 'class' => 'prev', 'rel' => 'prev'),
+ 'span' => array('class' => 'prev'),
+ 'a' => array('href' => '/?page=1', 'rel' => 'prev'),
'Prev',
'/a',
'/span'
Oops, something went wrong.

0 comments on commit 5d79299

Please sign in to comment.