mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
cc098629a6
commit
b0b9c1e4bd
2 changed files with 27 additions and 9 deletions
|
@ -311,7 +311,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
$title = $disabledTitle;
|
$title = $disabledTitle;
|
||||||
}
|
}
|
||||||
$options = array_merge($_defaults, (array)$disabledOptions);
|
$options = array_merge($_defaults, (array)$disabledOptions);
|
||||||
} elseif (!$this->{$check}()) {
|
} elseif (!$this->{$check}($options['model'])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
|
$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)));
|
return $this->link($title, $url, array_merge($options, array('escape' => $escape)));
|
||||||
} else {
|
} else {
|
||||||
return $this->Html->tag($tag, $title, $options, $escape);
|
return $this->Html->tag($tag, $title, $options, $escape);
|
||||||
|
|
|
@ -239,28 +239,46 @@ class PaginatorTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testUrlGenerationWithPrefixes() {
|
function testUrlGenerationWithPrefixes() {
|
||||||
$memberPrefixes = array('prefix' => 'members', 'members' => true);
|
$memberPrefixes = array('prefix' => 'members', 'members' => true);
|
||||||
Router::connect('/members/:controller/:action/*', $memberPrefixes);
|
Router::connect('/members/:controller/:action/*', $memberPrefixes);
|
||||||
Router::parse('/');
|
Router::parse('/');
|
||||||
|
|
||||||
Router::setRequestInfo( array(
|
Router::setRequestInfo( array(
|
||||||
array('controller' => 'posts', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null),
|
array('controller' => 'posts', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null),
|
||||||
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => 'posts/index', 'webroot' => '/')
|
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']['options']['page'] = 2;
|
||||||
|
$this->Paginator->params['paging']['Article']['page'] = 2;
|
||||||
|
$this->Paginator->params['paging']['Article']['prevPage'] = true;
|
||||||
$options = array('members' => true);
|
$options = array('members' => true);
|
||||||
|
|
||||||
$result = $this->Paginator->url($options);
|
$result = $this->Paginator->url($options);
|
||||||
$expected = '/members/posts/index/page:2';
|
$expected = '/members/posts/index/page:2';
|
||||||
$this->assertEqual($result, $expected);
|
$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'));
|
$options = array('controller' => 'posts', 'order' => array('Article.name' => 'desc'));
|
||||||
$result = $this->Paginator->url($options);
|
$result = $this->Paginator->url($options);
|
||||||
$expected = '/posts/index/page:2/sort:Article.name/direction:desc';
|
$expected = '/posts/index/page:2/sort:Article.name/direction:desc';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testOptions method
|
* testOptions method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue