HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //opt/remi/php56/root/usr/share/tests/pear/Pager/tests/pager_sliding_test.php
<?php
// $Id$

require_once 'simple_include.php';
require_once 'pager_include.php';

class TestOfPagerSliding extends UnitTestCase {
    var $pager;
    function TestOfPagerSliding($name='Test of Pager_Sliding') {
        parent::__construct($name);
    }
    function setUp() {
        $options = array(
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
            'perPage'  => 2,
            'mode'     => 'Sliding',
        );
        $this->pager = Pager::factory($options);
    }
    function tearDown() {
        unset($this->pager);
    }
    function testPageRangeByPageId1() {
        $this->assertEqual(array(1, 5), $this->pager->getPageRangeByPageId(1));
    }
    function testPageRangeByPageId4() {
        $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4));
    }
    function testPageRangeByPageId_outOfRange() {
        $this->assertEqual(array(0, 0), $this->pager->getPageRangeByPageId(20));
    }
    function testPageRangeByPageId2() {
        $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4));
    }
    function testGetPageData() {
        $this->assertEqual(array(0=>1, 1=>2), $this->pager->getPageData());
    }
    function testGetPageData2() {
        $this->assertEqual(array(2=>3, 3=>4), $this->pager->getPageData(2));
    }
    function testGetPageData_OutOfRange() {
        $this->assertEqual(false, $this->pager->getPageData(20));
    }
    function testClearIfVoid() {
        $this->assertTrue(strlen($this->pager->links) > 0);
        
        $options = array(
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
            'perPage'  => 20,
            'mode'     => 'Sliding',
        );
        $this->pager = Pager::factory($options);
        $this->assertEqual('', $this->pager->links);
    }
}
?>