3 require_once('simpletest/unit_tester.php');
4 require_once('simpletest/reporter.php');
6 class PageSelectorTest
extends UnitTestCase
{
8 require_once '../lib/pageselector.php';
9 $this->PageSelector
=& new PageSelector("http://localhost/?p=", 2, 10);
10 $this->PageSelector2
=& new PageSelector("http://localhost/?p=", 2, 30);
13 function test_getLinks() {
14 $result = $this->PageSelector
->getLinks(4);
15 $expected = array('previous' => 'http://localhost/?p=3',
16 '1' => 'http://localhost/?p=1',
17 '2' => 'http://localhost/?p=2',
18 '3' => 'http://localhost/?p=3',
20 '5' => 'http://localhost/?p=5',
21 'next' => 'http://localhost/?p=5');
22 $this->assertEqual( $expected, $result );
23 $result = $this->PageSelector2
->getLinks(10);
24 $expected = array('previous' => 'http://localhost/?p=9',
25 '5' => 'http://localhost/?p=5',
26 '6' => 'http://localhost/?p=6',
27 '7' => 'http://localhost/?p=7',
28 '8' => 'http://localhost/?p=8',
29 '9' => 'http://localhost/?p=9',
31 '11' => 'http://localhost/?p=11',
32 '12' => 'http://localhost/?p=12',
33 '13' => 'http://localhost/?p=13',
34 '14' => 'http://localhost/?p=14',
35 '15' => 'http://localhost/?p=15',
36 'next' => 'http://localhost/?p=11');
37 $this->assertEqual( $expected, $result );
38 $result = $this->PageSelector2
->getLinks(3);
39 $expected = array('previous' => 'http://localhost/?p=2',
40 '1' => 'http://localhost/?p=1',
41 '2' => 'http://localhost/?p=2',
43 '4' => 'http://localhost/?p=4',
44 '5' => 'http://localhost/?p=5',
45 '6' => 'http://localhost/?p=6',
46 '7' => 'http://localhost/?p=7',
47 '8' => 'http://localhost/?p=8',
48 '9' => 'http://localhost/?p=9',
49 '10' => 'http://localhost/?p=10',
50 '11' => 'http://localhost/?p=11',
51 'next' => 'http://localhost/?p=4');
52 $this->assertEqual( $expected, $result );
53 $result = $this->PageSelector2
->getLinks(14);
54 $expected = array('previous' => 'http://localhost/?p=13',
55 '5' => 'http://localhost/?p=5',
56 '6' => 'http://localhost/?p=6',
57 '7' => 'http://localhost/?p=7',
58 '8' => 'http://localhost/?p=8',
59 '9' => 'http://localhost/?p=9',
60 '10' => 'http://localhost/?p=10',
61 '11' => 'http://localhost/?p=11',
62 '12' => 'http://localhost/?p=12',
63 '13' => 'http://localhost/?p=13',
65 '15' => 'http://localhost/?p=15',
66 'next' => 'http://localhost/?p=15');
67 $this->assertEqual( $expected, $result );
71 $test = &new PageSelectorTest
;
72 $test->run(new HtmlReporter());