Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
848 florian 1
<?php
2
// $Id$
3
 
4
require_once 'simple_include.php';
5
require_once 'pager_include.php';
6
 
7
class TestOfPagerSliding extends UnitTestCase {
8
    var $pager;
9
    function TestOfPagerSliding($name='Test of Pager_Sliding') {
10
        $this->UnitTestCase($name);
11
    }
12
    function setUp() {
13
        $options = array(
14
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
15
            'perPage'  => 2,
16
            'mode'     => 'Sliding',
17
        );
18
        $this->pager = Pager::factory($options);
19
    }
20
    function tearDown() {
21
        unset($this->pager);
22
    }
23
    function testPageRangeByPageId1() {
24
        $this->assertEqual(array(1, 5), $this->pager->getPageRangeByPageId(1));
25
    }
26
    function testPageRangeByPageId4() {
27
        $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4));
28
    }
29
    function testPageRangeByPageId_outOfRange() {
30
        $this->assertEqual(array(0, 0), $this->pager->getPageRangeByPageId(20));
31
    }
32
    function testPageRangeByPageId2() {
33
        $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4));
34
    }
35
    function testGetPageData() {
36
        $this->assertEqual(array(0=>1, 1=>2), $this->pager->getPageData());
37
    }
38
    function testGetPageData2() {
39
        $this->assertEqual(array(2=>3, 3=>4), $this->pager->getPageData(2));
40
    }
41
    function testGetPageData_OutOfRange() {
42
        $this->assertEqual(false, $this->pager->getPageData(20));
43
    }
44
    function testClearIfVoid() {
45
        $this->assertTrue(strlen($this->pager->links) > 0);
46
 
47
        $options = array(
48
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
49
            'perPage'  => 20,
50
            'mode'     => 'Sliding',
51
        );
52
        $this->pager = Pager::factory($options);
53
        $this->assertEqual('', $this->pager->links);
54
    }
55
}
56
?>