Adding PaginatorHelper tests for additional custom URL settings

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7358 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-07-24 04:04:21 +00:00
parent cc098629a6
commit b0b9c1e4bd
2 changed files with 27 additions and 9 deletions

View file

@ -311,7 +311,7 @@ class PaginatorHelper extends AppHelper {
$title = $disabledTitle;
}
$options = array_merge($_defaults, (array)$disabledOptions);
} elseif (!$this->{$check}()) {
} elseif (!$this->{$check}($options['model'])) {
return null;
}
@ -321,7 +321,7 @@ class PaginatorHelper extends AppHelper {
}
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
if ($this->{$check}()) {
if ($this->{$check}($model)) {
return $this->link($title, $url, array_merge($options, array('escape' => $escape)));
} else {
return $this->Html->tag($tag, $title, $options, $escape);

View file

@ -239,28 +239,46 @@ class PaginatorTest extends CakeTestCase {
* @return void
*/
function testUrlGenerationWithPrefixes() {
$memberPrefixes = array('prefix' => 'members', 'members' => true);
$memberPrefixes = array('prefix' => 'members', 'members' => true);
Router::connect('/members/:controller/:action/*', $memberPrefixes);
Router::parse('/');
Router::parse('/');
Router::setRequestInfo( array(
array('controller' => 'posts', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null),
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => 'posts/index', 'webroot' => '/')
));
));
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
$this->Paginator->params['paging']['Article']['page'] = 2;
$this->Paginator->params['paging']['Article']['prevPage'] = true;
$options = array('members' => true);
$result = $this->Paginator->url($options);
$expected = '/members/posts/index/page:2';
$this->assertEqual($result, $expected);
$result = $this->Paginator->sort('name', null, array('url' => $options));
$expected = '<a href="/members/posts/index/page:2/sort:name/direction:asc">Name</a>';
$this->assertEqual($result, $expected);
$result = $this->Paginator->next('next', array('url' => $options));
$expected = '<a href="/members/posts/index/page:3">next</a>';
$this->assertEqual($result, $expected);
$result = $this->Paginator->prev('prev', array('url' => $options));
$expected = '<a href="/members/posts/index/page:1">prev</a>';
$this->assertEqual($result, $expected);
$options = array('members' => true, 'controller' => 'posts', 'order' => array('name' => 'desc'));
$result = $this->Paginator->url($options);
$expected = '/members/posts/index/page:2/sort:name/direction:desc';
$this->assertEqual($result, $expected);
$options = array('controller' => 'posts', 'order' => array('Article.name' => 'desc'));
$result = $this->Paginator->url($options);
$expected = '/posts/index/page:2/sort:Article.name/direction:desc';
$this->assertEqual($result, $expected);
}
/**
* testOptions method
*