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

  1. <?php
  2. // $Id: pager_jumping_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 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 = Pager::factory($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.     function testGetPageData() {
  46.         $this->assertEqual(array(0=>1, 1=>2, 2=>3, 3=>4, 4=>5), $this->pager->getPageData());
  47.     }
  48.     function testGetPageData2() {
  49.         $this->assertEqual(array(5=>6, 6=>7, 7=>8, 8=>9, 9=>10), $this->pager->getPageData(2));
  50.     }
  51.     function testGetPageData_OutOfRange() {
  52.         $this->assertEqual(false, $this->pager->getPageData(4));
  53.     }
  54.     /**
  55.      * Returns offsets for given pageID. Eg, if you pass pageID=5 and your
  56.      * delta is 2, it will return 3 and 7. A pageID of 6 would give you 4 and 8
  57.      * If the method is called without parameter, pageID is set to currentPage#.
  58.      *
  59.      * Given a PageId, it returns the limits of the range of pages displayed.
  60.      * While getOffsetByPageId() returns the offset of the data within the current
  61.      * page, this method returns the offsets of the page numbers interval.
  62.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  63.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  64.      * PageID of 11 would give you 11 and 20.
  65.      *
  66.      * @param pageID PageID to get offsets for
  67.      * @return array  First and last offsets
  68.      * @access public
  69.      */
  70.     /**
  71.      * Given a PageId, it returns the limits of the range of pages displayed.
  72.      * While getOffsetByPageId() returns the offset of the data within the
  73.      * current page, this method returns the offsets of the page numbers interval.
  74.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  75.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  76.      * PageID of 11 would give you 11 and 20.
  77.      *
  78.      * @param pageID PageID to get offsets for
  79.      * @return array  First and last offsets
  80.      * @access public
  81.      */
  82. }
  83. ?>