cvs: pear /Pager/tests pager_test.php

From: Date: Thu, 29 Apr 2004 20:18:39 +0000
Subject: cvs: pear /Pager/tests pager_test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-18976@lists.php.net to get a copy of this message
quipo Thu Apr 29 16:18:39 2004 EDT Modified files: /pear/Pager/tests pager_test.php Log: - use factory() instead of constructor - add a few tests for the getPerPageSelectBox() method http://cvs.php.net/diff.php/pear/Pager/tests/pager_test.php?r1=1.2&r2=1.3&ty=u Index: pear/Pager/tests/pager_test.php diff -u pear/Pager/tests/pager_test.php:1.2 pear/Pager/tests/pager_test.php:1.3 --- pear/Pager/tests/pager_test.php:1.2 Wed Dec 10 15:21:53 2003 +++ pear/Pager/tests/pager_test.php Thu Apr 29 16:18:38 2004 @@ -1,5 +1,5 @@ <?php -// $Id: pager_test.php,v 1.2 2003/12/10 20:21:53 quipo Exp $ +// $Id: pager_test.php,v 1.3 2004/04/29 20:18:38 quipo Exp $ require_once 'simple_include.php'; require_once 'pager_include.php'; @@ -15,7 +15,7 @@ 'perPage' => 5, ); - $this->pager = new Pager($options); + $this->pager = Pager::factory($options); } function tearDown() { unset($this->pager); @@ -53,5 +53,42 @@ function testOffsetByPageId_outOfRange() { $this->assertEqual(array(0, 0), $this->pager->getOffsetByPageId(20)); } + function testSelectBox() { + $selectBox = '<select name="'.$this->pager->_sessionVar.'">'; + $selectBox .= '<option value="5" selected="selected">5</option>'; + $selectBox .= '<option value="10">10</option>'; + $selectBox .= '<option value="15">15</option>'; + $selectBox .= '</select>'; + $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(5, 15, 5)); + } + function testSelectBoxWithString() { + $selectBox = '<select name="'.$this->pager->_sessionVar.'">'; + $selectBox .= '<option value="5" selected="selected">5 bugs</option>'; + $selectBox .= '<option value="10">10 bugs</option>'; + $selectBox .= '<option value="15">15 bugs</option>'; + $selectBox .= '</select>'; + $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(5, 15, 5, false, '%d bugs')); + } + function testSelectBoxWithShowAll() { + $selectBox = '<select name="'.$this->pager->_sessionVar.'">'; + $selectBox .= '<option value="3">3</option>'; + $selectBox .= '<option value="4">4</option>'; + $selectBox .= '<option value="5" selected="selected">5</option>'; + $selectBox .= '<option value="6">6</option>'; + $selectBox .= '<option value="10">10</option>'; + $selectBox .= '</select>'; + $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(3, 6, 1, true)); + } + function testSelectBoxWithShowAllAndText() { + $this->pager->_showAllText = 'Show All'; + $selectBox = '<select name="'.$this->pager->_sessionVar.'">'; + $selectBox .= '<option value="3">3 bugs</option>'; + $selectBox .= '<option value="4">4 bugs</option>'; + $selectBox .= '<option value="5" selected="selected">5 bugs</option>'; + $selectBox .= '<option value="6">6 bugs</option>'; + $selectBox .= '<option value="10">Show All</option>'; + $selectBox .= '</select>'; + $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(3, 6, 1, true, '%d bugs')); + } } ?> \ No newline at end of file

« previous php.pear.cvs (#18976) next »