home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / pager_sliding_test.php < prev    next >
Encoding:
PHP Script  |  2004-10-01  |  2.8 KB  |  73 lines

  1. <?php
  2. // $Id: pager_sliding_test.php,v 1.4 2004/05/11 09:14:22 quipo Exp $
  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.     /**
  45.      * Returns offsets for given pageID. Eg, if you pass pageID=5 and your
  46.      * delta is 2, it will return 3 and 7. A pageID of 6 would give you 4 and 8
  47.      * If the method is called without parameter, pageID is set to currentPage#.
  48.      *
  49.      * Given a PageId, it returns the limits of the range of pages displayed.
  50.      * While getOffsetByPageId() returns the offset of the data within the current
  51.      * page, this method returns the offsets of the page numbers interval.
  52.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  53.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  54.      * PageID of 11 would give you 11 and 20.
  55.      *
  56.      * @param pageID PageID to get offsets for
  57.      * @return array  First and last offsets
  58.      * @access public
  59.      */
  60.     /**
  61.      * Given a PageId, it returns the limits of the range of pages displayed.
  62.      * While getOffsetByPageId() returns the offset of the data within the
  63.      * current page, this method returns the offsets of the page numbers interval.
  64.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  65.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  66.      * PageID of 11 would give you 11 and 20.
  67.      *
  68.      * @param pageID PageID to get offsets for
  69.      * @return array  First and last offsets
  70.      * @access public
  71.      */
  72. }
  73. ?>