home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / pager_jumping_test.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.8 KB  |  74 lines

  1. <?php
  2. // $Id: pager_jumping_test.php,v 1.4 2003/11/17 20:08:08 quipo Exp $
  3.  
  4. require_once 'simple_include.php';
  5. require_once 'pager_include.php';
  6.  
  7. class TestOfPagerJumping extends UnitTestCase {
  8.     var $pager;
  9.     function TestOfPagerJumping($name='Test of Pager_Jumping') {
  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'  => 5,
  16.             'mode'     => 'Jumping',
  17.             'delta'    => 2
  18.         );
  19.         $this->pager = new Pager($options);
  20.     }
  21.     function tearDown() {
  22.         unset($this->pager);
  23.     }
  24.     function testPageIdByOffset1() {
  25.         $this->assertEqual(1, $this->pager->getPageIdByOffset(1));
  26.     }
  27.     function testPageIdByOffset5() {
  28.         $this->assertEqual(1, $this->pager->getPageIdByOffset(5));
  29.     }
  30.     function testPageIdByOffset6() {
  31.         $this->assertEqual(2, $this->pager->getPageIdByOffset(6));
  32.     }
  33.     function testPageRangeByPageId1() {
  34.         $this->assertEqual(array(1, 2), $this->pager->getPageRangeByPageId(1));
  35.     }
  36.     function testPageRangeByPageId2() {
  37.         $this->assertEqual(array(1, 2), $this->pager->getPageRangeByPageId(2));
  38.     }
  39.     function testPageRangeByPageId3() {
  40.         $this->assertEqual(array(3, 3), $this->pager->getPageRangeByPageId(3));
  41.     }
  42.     function testPageRangeByPageId_outOfRange() {
  43.         $this->assertEqual(array(0, 0), $this->pager->getPageRangeByPageId(20));
  44.     }
  45.     /**
  46.      * Returns offsets for given pageID. Eg, if you pass pageID=5 and your
  47.      * delta is 2, it will return 3 and 7. A pageID of 6 would give you 4 and 8
  48.      * If the method is called without parameter, pageID is set to currentPage#.
  49.      *
  50.      * Given a PageId, it returns the limits of the range of pages displayed.
  51.      * While getOffsetByPageId() returns the offset of the data within the current
  52.      * page, this method returns the offsets of the page numbers interval.
  53.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  54.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  55.      * PageID of 11 would give you 11 and 20.
  56.      *
  57.      * @param pageID PageID to get offsets for
  58.      * @return array  First and last offsets
  59.      * @access public
  60.      */
  61.     /**
  62.      * Given a PageId, it returns the limits of the range of pages displayed.
  63.      * While getOffsetByPageId() returns the offset of the data within the
  64.      * current page, this method returns the offsets of the page numbers interval.
  65.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  66.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  67.      * PageID of 11 would give you 11 and 20.
  68.      *
  69.      * @param pageID PageID to get offsets for
  70.      * @return array  First and last offsets
  71.      * @access public
  72.      */
  73. }
  74. ?>