mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Updated paginator.test.php to increase code coverage
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6767 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
8b42465eaf
commit
231d585221
1 changed files with 118 additions and 1 deletions
|
@ -159,6 +159,35 @@ class PaginatorTest extends UnitTestCase {
|
|||
$this->Paginator->params['paging']['Article']['options']['page'] = 2;
|
||||
$result = $this->Paginator->url();
|
||||
$this->assertEqual($result, '/index/page:2');
|
||||
|
||||
$options = array('order' => array('Article' => 'desc'));
|
||||
$result = $this->Paginator->url($options);
|
||||
$this->assertEqual($result, '/index/page:2/sort:Article/direction:desc');
|
||||
}
|
||||
|
||||
function testOptions() {
|
||||
$this->Paginator->options('myDiv');
|
||||
$this->assertEqual('myDiv', $this->Paginator->options['update']);
|
||||
|
||||
$this->Paginator->options = array();
|
||||
$this->Paginator->params = array();
|
||||
|
||||
$options = array('paging' => array(
|
||||
'Article' => array(
|
||||
'order' => 'desc',
|
||||
'sort' => 'title'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->Paginator->options($options);
|
||||
|
||||
$expected = array('Article' => array(
|
||||
'order' => 'desc',
|
||||
'sort' => 'title'
|
||||
)
|
||||
);
|
||||
$this->assertEqual($expected, $this->Paginator->params['paging']);
|
||||
|
||||
}
|
||||
|
||||
function testPagingLinks() {
|
||||
|
@ -288,6 +317,32 @@ class PaginatorTest extends UnitTestCase {
|
|||
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
'current' => 10,
|
||||
'count' => 30,
|
||||
'prevPage' => false,
|
||||
'nextPage' => 2,
|
||||
'pageCount' => 3,
|
||||
'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()
|
||||
)
|
||||
)
|
||||
);
|
||||
$options = array('modulus' => 10);
|
||||
$result = $this->Paginator->numbers($options);
|
||||
$expected = '<span class="current">1</span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
}
|
||||
|
||||
function testFirstAndLast() {
|
||||
|
@ -334,6 +389,68 @@ class PaginatorTest extends UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
function testCounter() {
|
||||
$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(),
|
||||
'separator' => 'of'
|
||||
),
|
||||
)
|
||||
);
|
||||
$input = 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%';
|
||||
$result = $this->Paginator->counter($input);
|
||||
$expected = 'Page 1 of 5, showing 3 records out of 13 total, starting on record 1, ending on 3';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$input = 'Page %page% of %pages%';
|
||||
$result = $this->Paginator->counter($input);
|
||||
$expected = 'Page 1 of 5';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Paginator->counter(array('format' => $input));
|
||||
$expected = 'Page 1 of 5';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Paginator->counter(array('format' => 'pages'));
|
||||
$expected = '1 of 5';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Paginator->counter(array('format' => 'range'));
|
||||
$expected = '1 - 3 of 13';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
}
|
||||
|
||||
function testHasPage() {
|
||||
$result = $this->Paginator->hasPage('Article', 15);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $this->Paginator->hasPage('UndefinedModel', 2);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $this->Paginator->hasPage('Article', 2);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = $this->Paginator->hasPage(2);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->Paginator);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue