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

  1. <?php
  2. // $Id: pager_sliding_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 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 = new Pager($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. //////////
  33.     function testPageRangeByPageId2() {
  34.         $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4));
  35.     }
  36.     /**
  37.      * Returns offsets for given pageID. Eg, if you pass pageID=5 and your
  38.      * delta is 2, it will return 3 and 7. A pageID of 6 would give you 4 and 8
  39.      * If the method is called without parameter, pageID is set to currentPage#.
  40.      *
  41.      * Given a PageId, it returns the limits of the range of pages displayed.
  42.      * While getOffsetByPageId() returns the offset of the data within the current
  43.      * page, this method returns the offsets of the page numbers interval.
  44.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  45.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  46.      * PageID of 11 would give you 11 and 20.
  47.      *
  48.      * @param pageID PageID to get offsets for
  49.      * @return array  First and last offsets
  50.      * @access public
  51.      */
  52.     /**
  53.      * Given a PageId, it returns the limits of the range of pages displayed.
  54.      * While getOffsetByPageId() returns the offset of the data within the
  55.      * current page, this method returns the offsets of the page numbers interval.
  56.      * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10.
  57.      * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10.
  58.      * PageID of 11 would give you 11 and 20.
  59.      *
  60.      * @param pageID PageID to get offsets for
  61.      * @return array  First and last offsets
  62.      * @access public
  63.      */
  64. }
  65. ?>