Skip to content

Commit

Permalink
Updating test cases for the addition of rel attributes to links gener…
Browse files Browse the repository at this point in the history
…ated by PaginatorHelper. Also removed rel attributes for disabled elements, as they are probably not link tags. Fixes #370
  • Loading branch information
markstory committed Dec 27, 2010
1 parent 6539460 commit af608f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
1 change: 1 addition & 0 deletions cake/libs/view/helpers/paginator.php
Expand Up @@ -454,6 +454,7 @@ protected function __pagingLink($which, $title = null, $options = array(), $disa
if ($this->{$check}($model)) {
return $this->Html->tag($tag, $this->link($title, $url, array_merge($options, compact('escape', 'class'))));
} else {
unset($options['rel']);
return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
}
}
Expand Down
48 changes: 30 additions & 18 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -460,7 +460,7 @@ function testSortAdminLinks() {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next'),
'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next', 'rel' => 'next'),
'Next',
'/a',
'/span'
Expand Down Expand Up @@ -563,7 +563,7 @@ function testUrlGenerationWithPrefixes() {
$result = $this->Paginator->next('next', array('url' => $options));
$expected = array(
'<span',
'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next'),
'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next', 'rel' => 'next'),
'next',
'/a',
'/span'
Expand All @@ -573,7 +573,7 @@ function testUrlGenerationWithPrefixes() {
$result = $this->Paginator->prev('prev', array('url' => $options));
$expected = array(
'<span',
'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev'),
'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
'prev',
'/a',
'/span'
Expand Down Expand Up @@ -700,7 +700,7 @@ function testPassedArgsMergingWithUrlOptions() {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'),
'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next', 'rel' => 'next'),
'Next',
'/a',
'/span'
Expand Down Expand Up @@ -750,7 +750,7 @@ function testPagingLinks() {
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
'&lt;&lt; Previous',
'/a',
'/span'
Expand All @@ -760,7 +760,7 @@ function testPagingLinks() {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/index/page:3', 'class' => 'next'),
'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'),
'Next',
'/a',
'/span'
Expand All @@ -770,7 +770,7 @@ function testPagingLinks() {
$result = $this->Paginator->next('Next', array('tag' => 'li'));
$expected = array(
'<li',
'a' => array('href' => '/index/page:3', 'class' => 'next'),
'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'),
'Next',
'/a',
'/li'
Expand All @@ -780,7 +780,7 @@ function testPagingLinks() {
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
'&lt;&lt; Previous',
'/a',
'/span'
Expand All @@ -790,7 +790,7 @@ function testPagingLinks() {
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'),
'preg:/<< Previous/',
'/a',
'/span'
Expand Down Expand Up @@ -858,7 +858,11 @@ function testPagingLinks() {
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'class' => 'prev'),
'a' => array(
'href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC',
'class' => 'prev',
'rel' => 'prev'
),
'&lt;&lt; Previous',
'/a',
'/span'
Expand All @@ -868,7 +872,11 @@ function testPagingLinks() {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC', 'class' => 'next'),
'a' => array(
'href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC',
'class' => 'next',
'rel' => 'next'
),
'Next',
'/a',
'/span'
Expand All @@ -895,7 +903,7 @@ function testPagingLinks() {
$result = $this->Paginator->prev('Prev');
$expected = array(
'<span',
'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev'),
'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev', 'rel' => 'prev'),
'Prev',
'/a',
'/span'
Expand All @@ -917,7 +925,7 @@ function testPagingLinks() {
$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'),
'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev', 'rel' => 'prev'),
'Prev',
'/a',
'/span'
Expand Down Expand Up @@ -957,7 +965,7 @@ function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
$result = $this->Paginator->next('Next >>', array('escape' => false));
$expected = array(
'<span',
'a' => array('href' => '/index/page:2', 'class' => 'next'),
'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'),
'preg:/Next >>/',
'/a',
'/span'
Expand Down Expand Up @@ -1004,7 +1012,7 @@ function testPagingLinksNotDefaultModel() {
$result = $this->Paginator->next('Next', array('model' => 'Client'));
$expected = array(
'<span',
'a' => array('href' => '/index/page:2', 'class' => 'next'),
'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'),
'Next',
'/a',
'/span'
Expand Down Expand Up @@ -2130,7 +2138,11 @@ function testNextLinkUsingDotNotation() {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', 'class' => 'next'),
'a' => array(
'href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc',
'class' => 'next',
'rel' => 'next'
),
'Next',
'/a',
'/span',
Expand Down Expand Up @@ -2224,7 +2236,7 @@ function testQuerystringNextAndPrev() {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/?page=3', 'class' => 'next'),
'a' => array('href' => '/?page=3', 'class' => 'next', 'rel' => 'next'),
'Next',
'/a',
'/span'
Expand All @@ -2234,7 +2246,7 @@ function testQuerystringNextAndPrev() {
$result = $this->Paginator->prev('Prev');
$expected = array(
'<span',
'a' => array('href' => '/?page=1', 'class' => 'prev'),
'a' => array('href' => '/?page=1', 'class' => 'prev', 'rel' => 'prev'),
'Prev',
'/a',
'/span'
Expand Down

0 comments on commit af608f6

Please sign in to comment.