Skip to content

Commit

Permalink
For paging links the 'class' attribute is now always applied to the w…
Browse files Browse the repository at this point in the history
…rapping tag for consistency. Closes #1759
  • Loading branch information
ADmad committed Aug 13, 2011
1 parent b781762 commit 5d79299
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 68 deletions.
90 changes: 43 additions & 47 deletions lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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',
);
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down

0 comments on commit 5d79299

Please sign in to comment.