From af608f68ef70ed17e0663cd37ae2f18bc85fb032 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 10:38:30 -0500 Subject: [PATCH] Updating test cases for the addition of rel attributes to links generated by PaginatorHelper. Also removed rel attributes for disabled elements, as they are probably not link tags. Fixes #370 --- cake/libs/view/helpers/paginator.php | 1 + .../libs/view/helpers/paginator.test.php | 48 ++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index c7377e13e92..fc4ba08627e 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -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'))); } } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 5176b3340a8..671c4f46a66 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -460,7 +460,7 @@ function testSortAdminLinks() { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/admin/users/index/page:2', 'class' => 'next'), + 'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -563,7 +563,7 @@ function testUrlGenerationWithPrefixes() { $result = $this->Paginator->next('next', array('url' => $options)); $expected = array( ' array('href' => '/members/posts/index/page:3', 'class' => 'next'), + 'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next', 'rel' => 'next'), 'next', '/a', '/span' @@ -573,7 +573,7 @@ function testUrlGenerationWithPrefixes() { $result = $this->Paginator->prev('prev', array('url' => $options)); $expected = array( ' array('href' => '/members/posts/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev', 'rel' => 'prev'), 'prev', '/a', '/span' @@ -700,7 +700,7 @@ function testPassedArgsMergingWithUrlOptions() { $result = $this->Paginator->next('Next'); $expected = array( ' 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' @@ -750,7 +750,7 @@ function testPagingLinks() { $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( ' array('href' => '/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'), '<< Previous', '/a', '/span' @@ -760,7 +760,7 @@ function testPagingLinks() { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/index/page:3', 'class' => 'next'), + 'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -770,7 +770,7 @@ function testPagingLinks() { $result = $this->Paginator->next('Next', array('tag' => 'li')); $expected = array( ' array('href' => '/index/page:3', 'class' => 'next'), + 'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/li' @@ -780,7 +780,7 @@ function testPagingLinks() { $result = $this->Paginator->prev('<< Previous', array('escape' => true)); $expected = array( ' array('href' => '/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'), '<< Previous', '/a', '/span' @@ -790,7 +790,7 @@ function testPagingLinks() { $result = $this->Paginator->prev('<< Previous', array('escape' => false)); $expected = array( ' array('href' => '/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'), 'preg:/<< Previous/', '/a', '/span' @@ -858,7 +858,11 @@ function testPagingLinks() { $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( ' 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' + ), '<< Previous', '/a', '/span' @@ -868,7 +872,11 @@ function testPagingLinks() { $result = $this->Paginator->next('Next'); $expected = array( ' 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' @@ -895,7 +903,7 @@ function testPagingLinks() { $result = $this->Paginator->prev('Prev'); $expected = array( ' array('href' => '/index/page:1/limit:10', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev', 'rel' => 'prev'), 'Prev', '/a', '/span' @@ -917,7 +925,7 @@ function testPagingLinks() { $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); $expected = array( ' 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' @@ -957,7 +965,7 @@ function testPagingLinksOptionsReplaceEmptyDisabledOptions() { $result = $this->Paginator->next('Next >>', array('escape' => false)); $expected = array( ' array('href' => '/index/page:2', 'class' => 'next'), + 'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'), 'preg:/Next >>/', '/a', '/span' @@ -1004,7 +1012,7 @@ function testPagingLinksNotDefaultModel() { $result = $this->Paginator->next('Next', array('model' => 'Client')); $expected = array( ' array('href' => '/index/page:2', 'class' => 'next'), + 'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -2130,7 +2138,11 @@ function testNextLinkUsingDotNotation() { $result = $this->Paginator->next('Next'); $expected = array( ' 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', @@ -2224,7 +2236,7 @@ function testQuerystringNextAndPrev() { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/?page=3', 'class' => 'next'), + 'a' => array('href' => '/?page=3', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -2234,7 +2246,7 @@ function testQuerystringNextAndPrev() { $result = $this->Paginator->prev('Prev'); $expected = array( ' array('href' => '/?page=1', 'class' => 'prev'), + 'a' => array('href' => '/?page=1', 'class' => 'prev', 'rel' => 'prev'), 'Prev', '/a', '/span'