cvs: pear /Pager/tests pager_jumping_test.php pager_sliding_notExpanded_test.php pager_sliding_test.php pager_sliding_tests.php pager_test.php

From: Date: Wed, 10 Dec 2003 20:21:53 +0000
Subject: cvs: pear /Pager/tests pager_jumping_test.php pager_sliding_notExpanded_test.php pager_sliding_test.php pager_sliding_tests.php pager_test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-14774@lists.php.net to get a copy of this message
quipo Wed Dec 10 15:21:53 2003 EDT Added files: /pear/Pager/tests pager_sliding_notExpanded_test.php Modified files: /pear/Pager/tests pager_jumping_test.php pager_sliding_test.php pager_sliding_tests.php pager_test.php Log: added more tests

Index: pear/Pager/tests/pager_jumping_test.php diff -u pear/Pager/tests/pager_jumping_test.php:1.1 pear/Pager/tests/pager_jumping_test.php:1.2 --- pear/Pager/tests/pager_jumping_test.php:1.1 Sun Nov 30 12:30:01 2003 +++ pear/Pager/tests/pager_jumping_test.php Wed Dec 10 15:21:53 2003 @@ -1,5 +1,5 @@ <?php -// $Id: pager_jumping_test.php,v 1.1 2003/11/30 17:30:01 quipo Exp $ +// $Id: pager_jumping_test.php,v 1.2 2003/12/10 20:21:53 quipo Exp $ require_once 'simple_include.php'; require_once 'pager_include.php'; @@ -12,31 +12,63 @@ function setUp() { $options = array( 'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - 'perPage' => 3, + 'perPage' => 5, 'mode' => 'Jumping', + 'delta' => 2 ); $this->pager = new Pager($options); } function tearDown() { unset($this->pager); } - function testOffsetByPageId() { - $this->assertEqual(array(1, 3), $this->pager->getOffsetByPageId(1)); - } - function testOffsetByPageId2() { - $this->assertEqual(array(4, 6), $this->pager->getOffsetByPageId(2)); - } - function testOffsetByPageId_outOfRange() { - $this->assertEqual(array(0, 0), $this->pager->getOffsetByPageId(6)); - } - function testPageIdByOffset() { + function testPageIdByOffset1() { $this->assertEqual(1, $this->pager->getPageIdByOffset(1)); } - function testPageIdByOffset2() { - $this->assertEqual(1, $this->pager->getPageIdByOffset(2)); + function testPageIdByOffset5() { + $this->assertEqual(1, $this->pager->getPageIdByOffset(5)); + } + function testPageIdByOffset6() { + $this->assertEqual(2, $this->pager->getPageIdByOffset(6)); } - function testPageIdByOffset3() { - $this->assertEqual(2, $this->pager->getPageIdByOffset(5)); + function testPageRangeByPageId1() { + $this->assertEqual(array(1, 2), $this->pager->getPageRangeByPageId(1)); } + function testPageRangeByPageId2() { + $this->assertEqual(array(1, 2), $this->pager->getPageRangeByPageId(2)); + } + function testPageRangeByPageId3() { + $this->assertEqual(array(3, 3), $this->pager->getPageRangeByPageId(3)); + } + function testPageRangeByPageId_outOfRange() { + $this->assertEqual(array(0, 0), $this->pager->getPageRangeByPageId(20)); + } + /** + * Returns offsets for given pageID. Eg, if you pass pageID=5 and your + * delta is 2, it will return 3 and 7. A pageID of 6 would give you 4 and 8 + * If the method is called without parameter, pageID is set to currentPage#. + * + * Given a PageId, it returns the limits of the range of pages displayed. + * While getOffsetByPageId() returns the offset of the data within the current + * page, this method returns the offsets of the page numbers interval. + * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10. + * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10. + * PageID of 11 would give you 11 and 20. + * + * @param pageID PageID to get offsets for + * @return array First and last offsets + * @access public + */ + /** + * Given a PageId, it returns the limits of the range of pages displayed. + * While getOffsetByPageId() returns the offset of the data within the + * current page, this method returns the offsets of the page numbers interval. + * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10. + * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10. + * PageID of 11 would give you 11 and 20. + * + * @param pageID PageID to get offsets for + * @return array First and last offsets + * @access public + */ } ?> \ No newline at end of file Index: pear/Pager/tests/pager_sliding_test.php diff -u pear/Pager/tests/pager_sliding_test.php:1.1 pear/Pager/tests/pager_sliding_test.php:1.2 --- pear/Pager/tests/pager_sliding_test.php:1.1 Sun Nov 30 12:30:01 2003 +++ pear/Pager/tests/pager_sliding_test.php Wed Dec 10 15:21:53 2003 @@ -1,5 +1,5 @@ <?php -// $Id: pager_sliding_test.php,v 1.1 2003/11/30 17:30:01 quipo Exp $ +// $Id: pager_sliding_test.php,v 1.2 2003/12/10 20:21:53 quipo Exp $ require_once 'simple_include.php'; require_once 'pager_include.php'; @@ -20,14 +20,46 @@ function tearDown() { unset($this->pager); } - function testOffsetByPageId() { - $this->assertEqual(array(1, 5), $this->pager->getOffsetByPageId(2)); + function testPageRangeByPageId1() { + $this->assertEqual(array(1, 5), $this->pager->getPageRangeByPageId(1)); } - function testOffsetByPageId2() { - $this->assertEqual(array(2, 6), $this->pager->getOffsetByPageId(6)); + function testPageRangeByPageId4() { + $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4)); } - function testOffsetByPageId_outOfRange() { - $this->assertEqual(array(0, 0), $this->pager->getOffsetByPageId(20)); + function testPageRangeByPageId_outOfRange() { + $this->assertEqual(array(0, 0), $this->pager->getPageRangeByPageId(20)); } +////////// + function testPageRangeByPageId2() { + $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4)); + } + /** + * Returns offsets for given pageID. Eg, if you pass pageID=5 and your + * delta is 2, it will return 3 and 7. A pageID of 6 would give you 4 and 8 + * If the method is called without parameter, pageID is set to currentPage#. + * + * Given a PageId, it returns the limits of the range of pages displayed. + * While getOffsetByPageId() returns the offset of the data within the current + * page, this method returns the offsets of the page numbers interval. + * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10. + * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10. + * PageID of 11 would give you 11 and 20. + * + * @param pageID PageID to get offsets for + * @return array First and last offsets + * @access public + */ + /** + * Given a PageId, it returns the limits of the range of pages displayed. + * While getOffsetByPageId() returns the offset of the data within the + * current page, this method returns the offsets of the page numbers interval. + * E.g., if you have perPage=10 and pageId=3, it will return you 1 and 10. + * PageID of 8 would give you 1 and 10 as well, because 1 <= 8 <= 10. + * PageID of 11 would give you 11 and 20. + * + * @param pageID PageID to get offsets for + * @return array First and last offsets + * @access public + */ } ?> \ No newline at end of file Index: pear/Pager/tests/pager_sliding_tests.php diff -u pear/Pager/tests/pager_sliding_tests.php:1.1 pear/Pager/tests/pager_sliding_tests.php:1.2 --- pear/Pager/tests/pager_sliding_tests.php:1.1 Sun Nov 30 12:30:01 2003 +++ pear/Pager/tests/pager_sliding_tests.php Wed Dec 10 15:21:53 2003 @@ -1,5 +1,5 @@ <?php -// $Id: pager_sliding_tests.php,v 1.1 2003/11/30 17:30:01 quipo Exp $ +// $Id: pager_sliding_tests.php,v 1.2 2003/12/10 20:21:53 quipo Exp $ require_once 'simple_include.php'; require_once 'pager_include.php'; @@ -8,6 +8,7 @@ function PagerSlidingTests() { $this->GroupTest('Pager_Sliding Tests'); $this->addTestFile('pager_sliding_test.php'); + $this->addTestFile('pager_sliding_notExpanded_test.php'); $this->addTestFile('pager_sliding_noData_test.php'); } } Index: pear/Pager/tests/pager_test.php diff -u pear/Pager/tests/pager_test.php:1.1 pear/Pager/tests/pager_test.php:1.2 --- pear/Pager/tests/pager_test.php:1.1 Sun Nov 30 12:30:01 2003 +++ pear/Pager/tests/pager_test.php Wed Dec 10 15:21:53 2003 @@ -1,5 +1,5 @@ <?php -// $Id: pager_test.php,v 1.1 2003/11/30 17:30:01 quipo Exp $ +// $Id: pager_test.php,v 1.2 2003/12/10 20:21:53 quipo Exp $ require_once 'simple_include.php'; require_once 'pager_include.php'; @@ -44,5 +44,14 @@ function testLastPageComplete () { $this->assertEqual(true, $this->pager->isLastPageComplete()); } + function testOffsetByPageId1() { + $this->assertEqual(array(1, 5), $this->pager->getOffsetByPageId(1)); + } + function testOffsetByPageId2() { + $this->assertEqual(array(6, 10), $this->pager->getOffsetByPageId(2)); + } + function testOffsetByPageId_outOfRange() { + $this->assertEqual(array(0, 0), $this->pager->getOffsetByPageId(20)); + } } ?> \ No newline at end of file Index: pear/Pager/tests/pager_sliding_notExpanded_test.php +++ pear/Pager/tests/pager_sliding_notExpanded_test.php <?php // $Id: pager_sliding_notExpanded_test.php,v 1.1 2003/12/10 20:21:53 quipo Exp $ require_once 'simple_include.php'; require_once 'pager_include.php'; class TestOfPagerSlidingNotExpanded extends UnitTestCase { var $pager; function TestOfPagerSlidingNotExpanded($name='Test of Pager_Sliding - expanded=false') { $this->UnitTestCase($name); } function setUp() { $options = array( 'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21), 'perPage' => 2, 'mode' => 'Sliding', 'expanded' => false ); $this->pager = new Pager($options); } function tearDown() { unset($this->pager); } function testPageRangeByPageId1() { $this->assertEqual(array(1, 3), $this->pager->getPageRangeByPageId(1)); } function testPageRangeByPageId2() { $this->assertEqual(array(1, 4), $this->pager->getPageRangeByPageId(2)); } function testPageRangeByPageId3() { $this->assertEqual(array(1, 5), $this->pager->getPageRangeByPageId(3)); } function testPageRangeByPageId4() { $this->assertEqual(array(2, 6), $this->pager->getPageRangeByPageId(4)); } function testPageRangeByPageId9() { $this->assertEqual(array(7, 11), $this->pager->getPageRangeByPageId(9)); } function testPageRangeByPageId10() { $this->assertEqual(array(8, 11), $this->pager->getPageRangeByPageId(10)); } function testPageRangeByPageId11() { $this->assertEqual(array(9, 11), $this->pager->getPageRangeByPageId(11)); } function testPageRangeByPageId_outOfRange() { $this->assertEqual(array(0, 0), $this->pager->getPageRangeByPageId(20)); } } ?>
« previous php.pear.cvs (#14774) next »