mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Array handling fix for Paginator and additional test cases
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6132 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c2db2a3936
commit
0b9f2c1b9d
2 changed files with 19 additions and 7 deletions
|
@ -174,9 +174,8 @@ class PaginatorHelper extends AppHelper {
|
|||
|
||||
if ($dir == 'desc') {
|
||||
return 'desc';
|
||||
} else {
|
||||
return 'asc';
|
||||
}
|
||||
return 'asc';
|
||||
}
|
||||
/**
|
||||
* Generates a "previous" link for a set of paged records
|
||||
|
@ -273,11 +272,8 @@ class PaginatorHelper extends AppHelper {
|
|||
*/
|
||||
function __pagingLink($which, $title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
||||
$check = 'has' . $which;
|
||||
$_defaults = array(
|
||||
'url' => array(), 'step' => 1,
|
||||
'escape' => true, 'model' => null
|
||||
);
|
||||
$options = array_merge($_defaults, $options);
|
||||
$_defaults = array('url' => array(), 'step' => 1, 'escape' => true, 'model' => null);
|
||||
$options = array_merge($_defaults, (array)$options);
|
||||
$paging = $this->params($options['model']);
|
||||
|
||||
if (!$this->{$check}() && (!empty($disabledTitle) || !empty($disabledOptions))) {
|
||||
|
|
|
@ -126,6 +126,22 @@ class PaginatorTest extends UnitTestCase {
|
|||
$this->assertPattern('/\/sort:controller\//', $result);
|
||||
}
|
||||
|
||||
function testPagingLinks() {
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
|
||||
);
|
||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||
$expected = '<div class="disabled"><< Previous</div>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 2;
|
||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||
$this->assertPattern('/^<a[^<>]+><< Previous<\/a>$/', $result);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->Paginator);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue