Subversion Repositories Applications.papyrus

Rev

Rev 1371 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
848 florian 1
<?php
2
// $Id$
3
 
4
require_once 'simple_include.php';
5
require_once 'pager_include.php';
6
 
7
class TestOfPager extends UnitTestCase {
8
    var $pager;
9
    var $baseurl;
10
    function TestOfPager($name='Test of Pager') {
11
        $this->UnitTestCase($name);
12
    }
13
    function setUp() {
14
        $options = array(
15
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
16
            'perPage'  => 5,
17
        );
18
        $this->pager = Pager::factory($options);
19
        $this->baseurl = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
20
    }
21
    function tearDown() {
22
        unset($this->pager);
23
    }
24
    function testCurrentPageID () {
25
        $this->assertEqual(1, $this->pager->getCurrentPageID());
26
    }
27
    function testNextPageID () {
28
        $this->assertEqual(2, $this->pager->getNextPageID());
29
    }
30
    function testPrevPageID () {
31
        $this->assertEqual(false, $this->pager->getPreviousPageID());
32
    }
33
    function testNumItems () {
34
        $this->assertEqual(10, $this->pager->numItems());
35
    }
36
    function testNumPages () {
37
        $this->assertEqual(2, $this->pager->numPages());
38
    }
39
    function testFirstPage () {
40
        $this->assertEqual(true, $this->pager->isFirstPage());
41
    }
42
    function testLastPage () {
43
        $this->assertEqual(false, $this->pager->isLastPage());
44
    }
45
    function testLastPageComplete () {
46
        $this->assertEqual(true, $this->pager->isLastPageComplete());
47
    }
48
    function testOffsetByPageId() {
49
        $this->assertEqual(array(1, 5), $this->pager->getOffsetByPageId(1));
50
        $this->assertEqual(array(6, 10), $this->pager->getOffsetByPageId(2));
51
    }
52
    function testOffsetByPageId_outOfRange() {
53
        $this->assertEqual(array(0, 0), $this->pager->getOffsetByPageId(20));
54
    }
55
    function testGetPageData() {
56
        $this->assertEqual(array(0=>1, 1=>2, 2=>3, 3=>4, 4=>5), $this->pager->getPageData());
57
        $this->assertEqual(array(5=>6, 6=>7, 7=>8, 8=>9, 9=>10), $this->pager->getPageData(2));
58
    }
59
    function testGetPageData_OutOfRange() {
60
        $this->assertEqual(array(), $this->pager->getPageData(3));
61
    }
62
    function testSelectBox() {
63
        $selectBox  = '<select name="'.$this->pager->_sessionVar.'">';
64
        $selectBox .= '<option value="5" selected="selected">5</option>';
65
        $selectBox .= '<option value="10">10</option>';
66
        $selectBox .= '<option value="15">15</option>';
67
        $selectBox .= '</select>';
68
        $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(5, 15, 5));
69
    }
70
    function testSelectBoxWithString() {
71
        $selectBox  = '<select name="'.$this->pager->_sessionVar.'">';
72
        $selectBox .= '<option value="5" selected="selected">5 bugs</option>';
73
        $selectBox .= '<option value="10">10 bugs</option>';
74
        $selectBox .= '<option value="15">15 bugs</option>';
75
        $selectBox .= '</select>';
76
        $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(5, 15, 5, false, '%d bugs'));
77
    }
78
    function testSelectBoxWithShowAll() {
79
        $selectBox  = '<select name="'.$this->pager->_sessionVar.'">';
80
        $selectBox .= '<option value="3">3</option>';
81
        $selectBox .= '<option value="4">4</option>';
82
        $selectBox .= '<option value="5" selected="selected">5</option>';
83
        $selectBox .= '<option value="6">6</option>';
84
        $selectBox .= '<option value="10">10</option>';
85
        $selectBox .= '</select>';
86
        $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(3, 6, 1, true));
87
    }
88
    function testSelectBoxWithShowAllAndText() {
89
        $this->pager->_showAllText = 'Show All';
90
        $selectBox  = '<select name="'.$this->pager->_sessionVar.'">';
91
        $selectBox .= '<option value="3">3 bugs</option>';
92
        $selectBox .= '<option value="4">4 bugs</option>';
93
        $selectBox .= '<option value="5" selected="selected">5 bugs</option>';
94
        $selectBox .= '<option value="6">6 bugs</option>';
95
        $selectBox .= '<option value="10">Show All</option>';
96
        $selectBox .= '</select>';
97
        $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(3, 6, 1, true, '%d bugs'));
98
    }
99
    function testSelectBoxWithShowAllWithExtraAttribs() {
100
        $this->pager->_showAllText = 'Show All';
101
        $selectBox  = '<select name="'.$this->pager->_sessionVar.'" onmouseover="doSth">';
102
        $selectBox .= '<option value="3">3 bugs</option>';
103
        $selectBox .= '<option value="4">4 bugs</option>';
104
        $selectBox .= '<option value="5" selected="selected">5 bugs</option>';
105
        $selectBox .= '<option value="6">6 bugs</option>';
106
        $selectBox .= '<option value="10">Show All</option>';
107
        $selectBox .= '</select>';
108
        $params = array('optionText' => '%d bugs', 'attributes' => 'onmouseover="doSth"');
109
        $this->assertEqual($selectBox, $this->pager->getPerPageSelectBox(3, 6, 1, true, $params));
110
    }
111
    function testSelectBoxInvalid() {
112
        $err = $this->pager->getPerPageSelectBox(5, 15, 5, false, '%s bugs');
113
        $this->assertEqual(ERROR_PAGER_INVALID_PLACEHOLDER, $err->getCode());
114
    }
115
    function testAppendInvalid() {
116
        $options = array(
117
            'totalItems' => 10,
118
            'append'     => false,
119
            'fileName'   => 'invalidFileName'
120
        );
121
        $err =& Pager::factory($options);  //ERROR_PAGER_INVALID_USAGE
122
        $this->assertError();
123
    }
124
    function testAppendValid() {
125
        $options = array(
126
            'totalItems' => 10,
127
            'append'     => false,
128
            'fileName'   => 'valid_%d_FileName'
129
        );
130
        $err =& Pager::factory($options);
131
        $this->assertNoErrors();
132
    }
133
    function testEscapeEntities() {
134
        //encode special chars
135
        $options = array(
136
            'extraVars' => array(
137
                'request' => array('aRequest'),
138
                'escape'    => 'äö%<>+',
139
            ),
140
            'perPage' => 5,
141
        );
142
        $this->pager =& Pager::factory($options);
143
        //$expected = '?request[]=aRequest&amp;escape=&auml;&ouml;%&lt;&gt;+&amp;pageID=';
144
        //$this->assertEqual($expected, $this->pager->_getLinksUrl());
145
 
146
        $expected = 'request%5B0%5D=aRequest&amp;escape=%E4%F6%25%3C%3E%2B';
147
        $rendered = $this->pager->_renderLink('', '');
148
        preg_match('/href="(.*)"/U', $rendered, $matches);
149
        $actual = str_replace($_SERVER['PHP_SELF'].'?', '', $matches[1]);
150
        $this->assertEqual($expected, $actual);
151
 
152
        //don't encode slashes
153
        $options = array(
154
            'extraVars' => array(
155
                'request' => 'cat/subcat',
156
            ),
157
            'perPage' => 5,
158
        );
159
        $this->pager =& Pager::factory($options);
160
        //$expected = '?request=cat/subcat&amp;pageID=';
161
        //$this->assertEqual($expected, $this->pager->_getLinksUrl());
162
        $expected = '<a href="'.$_SERVER['PHP_SELF'].'?request=cat/subcat" title=""></a>';
163
        $actual = $this->pager->_renderLink('', '');
164
        $this->assertEqual($expected, $actual);
165
    }
166
    function testMultibyteStrings() {
167
        $options = array(
168
            'extraVars' => array(
169
                'test' => '&#27979;&#35797;',
170
            ),
171
            'perPage' => 5,
172
        );
173
        $this->pager =& Pager::factory($options);
174
        //$expected = '<a href="'.$_SERVER['PHP_SELF'].'?test=&#27979;&#35797;" title=""></a>';
175
        $rendered = $this->pager->_renderLink('', '');
176
        preg_match('/href="(.*)"/U', $rendered, $matches);
177
        $actual = str_replace($_SERVER['PHP_SELF'].'?test=', '', $matches[1]);
178
        $this->assertEqual(urlencode($options['extraVars']['test']), $actual);
179
    }
180
    function testCurrentPage() {
181
        $options = array(
182
            'itemData'    => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
183
            'perPage'     => 2,
184
            'currentPage' => 2,
185
        );
186
        $this->pager =& Pager::factory($options);
187
        $this->assertEqual(3, $this->pager->getNextPageID());
188
        $this->assertEqual(1, $this->pager->getPreviousPageID());
189
        $this->assertEqual(2, $this->pager->_currentPage);
190
    }
191
    function testArrayExtraVars() {
192
        $arr = array(
193
            'apple',
194
            'orange',
195
        );
196
        $options = array(
197
            'itemData'    => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
198
            'perPage'     => 5,
199
            'extraVars'   => array('arr' => $arr, 'no' => 'test'),
200
        );
201
        $this->pager =& Pager::factory($options);
202
        /*
203
        //old
204
        $expected = '?arr[0]=apple&amp;arr[1]=orange&amp;pageID=';
205
        $this->assertEqual($expected, $this->pager->_getLinksUrl());
206
        */
207
        $expected = $options['extraVars'];
208
        $this->assertEqual($expected, $this->pager->_getLinksData());
209
 
210
        $expected = '<a href="'.$_SERVER['PHP_SELF'].'?arr%5B0%5D=apple&amp;arr%5B1%5D=orange&amp;no=test&amp;pageID=2" title=""></a>';
211
        $actual = $this->pager->_renderLink('', '');
212
        $this->assertEqual($expected, $actual);
213
    }
214
    function testExcludeVars() {
215
        $arr = array(
216
            'apple',
217
            'orange',
218
        );
219
        $options = array(
220
            'itemData'    => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
221
            'perPage'     => 5,
222
            'extraVars'   => array('arr' => $arr, 'no' => 'test'),
223
            'excludeVars' => array('no'),
224
        );
225
        $this->pager =& Pager::factory($options);
226
        $expected = array(
227
            'arr' => array(
228
 
229
                1 => 'orange'
230
            ),
231
        );
232
        $actual = $this->pager->_getLinksData();
233
        $this->assertEqual($expected, $this->pager->_getLinksData());
234
 
235
        $expected = '<a href="'.$_SERVER['PHP_SELF'].'?arr%5B0%5D=apple&amp;arr%5B1%5D=orange&amp;pageID=2" title=""></a>';
236
        $actual = $this->pager->_renderLink('', '');
237
        $this->assertEqual($expected, $actual);
238
    }
239
    function testArgSeparator() {
240
        $bkp_arg_separator = ini_get('arg_separator.output');
241
        ini_set('arg_separator.output', '&amp;');
242
 
243
        $options = array(
244
            'itemData'    => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
245
            'perPage'     => 5,
246
            'extraVars'   => array('apple'  => 1),
247
        );
248
        $this->pager =& Pager::factory($options);
249
 
250
        $expected = '<a href="'.$_SERVER['PHP_SELF'].'?apple=1&amp;pageID=2" title=""></a>';
251
        $actual = $this->pager->_renderLink('', '');
252
        $this->assertEqual($expected, $actual);
253
 
254
        ini_set('arg_separator.output', $bkp_arg_separator);
255
    }
256
    function testAttributes() {
257
        $options = array(
258
            'itemData'    => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
259
            'perPage'     => 5,
260
            'linkClass'   => 'testclass',
261
            'attributes'  => 'target="_blank"',
262
        );
263
        $this->pager =& Pager::factory($options);
264
 
265
        $expected = '<a href="'.$_SERVER['PHP_SELF'].'?pageID=2" class="testclass" target="_blank" title=""></a>';
266
        $actual = $this->pager->_renderLink('', '');
267
        $this->assertEqual($expected, $actual);
268
    }
269
    function testImportQuery() {
270
        //add some fake url vars
271
        $_GET['arr'] = array(
272
            'apple',
273
            'orange',
274
        );
275
        $options = array(
276
            'itemData'    => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
277
            'perPage'     => 5,
278
            'importQuery' => false,
279
        );
280
        $this->pager =& Pager::factory($options);
281
        $expected = array();
282
        $actual = $this->pager->_getLinksData();
283
        $this->assertEqual($expected, $this->pager->_getLinksData());
284
 
285
        $expected = '<a href="'.$_SERVER['PHP_SELF'].'?pageID=2" title=""></a>';
286
        $actual = $this->pager->_renderLink('', '');
287
        $this->assertEqual($expected, $actual);
288
        //remove fake url vars
289
        unset($_GET['arr']);
290
    }
291
    function testGetNextLinkTag() {
292
        //append = true
293
        $expected = '<link rel="next" href="'.$_SERVER['PHP_SELF'].'?pageID=2" title="next page" />'."\n";
294
        $this->assertEqual($expected, $this->pager->_getNextLinkTag());
295
 
296
        //append = false
297
        $options = array(
298
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
299
            'perPage'  => 5,
300
            'currentPage' => 1,
301
            'append'   => false,
302
            'fileName' => 'myfile.%d.php',
303
        );
304
        $this->pager = Pager::factory($options);
305
        $expected = '<link rel="next" href="'.$this->baseurl.'/myfile.2.php" title="next page" />'."\n";
306
        $this->assertEqual($expected, $this->pager->_getNextLinkTag());
307
 
308
        //test empty tag
309
        $options['currentPage'] = 2;
310
        $this->pager = Pager::factory($options);
311
        $this->assertEqual('', $this->pager->_getNextLinkTag());
312
    }
313
    function testGetLastLinkTag() {
314
        //append = true
315
        $expected = '<link rel="last" href="'.$_SERVER['PHP_SELF'].'?pageID=2" title="last page" />'."\n";
316
        $this->assertEqual($expected, $this->pager->_getLastLinkTag());
317
 
318
        //append = false
319
        $options = array(
320
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
321
            'perPage'  => 5,
322
            'currentPage' => 1,
323
            'append'   => false,
324
            'fileName' => 'myfile.%d.php',
325
        );
326
        $this->pager = Pager::factory($options);
327
        $expected = '<link rel="last" href="'.$this->baseurl.'/myfile.2.php" title="last page" />'."\n";
328
        $this->assertEqual($expected, $this->pager->_getLastLinkTag());
329
 
330
        //test empty tag
331
        $options['currentPage'] = 2;
332
        $this->pager = Pager::factory($options);
333
        $this->assertEqual('', $this->pager->_getLastLinkTag());
334
    }
335
    function testGetFirstLinkTag() {
336
        //append = true
337
        $options = array(
338
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
339
            'perPage'  => 5,
340
            'currentPage' => 2,
341
        );
342
        $this->pager = Pager::factory($options);
343
        $expected = '<link rel="first" href="'.$_SERVER['PHP_SELF'].'?pageID=1" title="first page" />'."\n";
344
        $this->assertEqual($expected, $this->pager->_getFirstLinkTag());
345
 
346
        //append = false
347
        $options = array(
348
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
349
            'perPage'  => 5,
350
            'currentPage' => 2,
351
            'append'   => false,
352
            'fileName' => 'myfile.%d.php',
353
        );
354
        $this->pager = Pager::factory($options);
355
        $expected = '<link rel="first" href="'.$this->baseurl.'/myfile.1.php" title="first page" />'."\n";
356
        $this->assertEqual($expected, $this->pager->_getFirstLinkTag());
357
 
358
        //test empty tag
359
        $options['currentPage'] = 1;
360
        $this->pager = Pager::factory($options);
361
        $this->assertEqual('', $this->pager->_getFirstLinkTag());
362
    }
363
    function testGetPrevLinkTag() {
364
        //append = true
365
        $options = array(
366
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
367
            'perPage'  => 5,
368
            'currentPage' => 2,
369
        );
370
        $this->pager = Pager::factory($options);
371
        $expected = '<link rel="previous" href="'.$_SERVER['PHP_SELF'].'?pageID=1" title="previous page" />'."\n";
372
        $this->assertEqual($expected, $this->pager->_getPrevLinkTag());
373
 
374
        //append = false
375
        $options = array(
376
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
377
            'perPage'  => 5,
378
            'currentPage' => 2,
379
            'append'   => false,
380
            'fileName' => 'myfile.%d.php',
381
        );
382
        $this->pager = Pager::factory($options);
383
        $expected = '<link rel="previous" href="'.$this->baseurl.'/myfile.1.php" title="previous page" />'."\n";
384
        $this->assertEqual($expected, $this->pager->_getPrevLinkTag());
385
 
386
        //test empty tag
387
        $options['currentPage'] = 1;
388
        $this->pager = Pager::factory($options);
389
        $this->assertEqual('', $this->pager->_getPrevLinkTag());
390
    }
391
    function testPrintFirstPage() {
392
        $options = array(
393
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
394
            'perPage'  => 5,
395
            'currentPage' => 2,
396
        );
397
        $this->pager = Pager::factory($options);
398
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=1" title="first page">[1]</a>&nbsp;';
399
        $this->assertEqual($expected, $this->pager->_printFirstPage());
400
 
401
        $this->pager->_firstPageText = 'FIRST';
402
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=1" title="first page">[FIRST]</a>&nbsp;';
403
        $this->assertEqual($expected, $this->pager->_printFirstPage());
404
 
405
        $options = array(
406
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
407
            'perPage'  => 5,
408
            'currentPage' => 2,
409
            'altFirst' => 'page %d',
410
        );
411
        $this->pager = Pager::factory($options);
412
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=1" title="page 1">[1]</a>&nbsp;';
413
        $this->assertEqual($expected, $this->pager->_printFirstPage());
414
    }
415
    function testPrintLastPage() {
416
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=2" title="last page">[2]</a>';
417
        $this->assertEqual($expected, $this->pager->_printLastPage());
418
 
419
        $this->pager->_lastPageText = 'LAST';
420
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=2" title="last page">[LAST]</a>';
421
        $this->assertEqual($expected, $this->pager->_printLastPage());
422
 
423
        $this->pager->_altLast = 'page %d';
424
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=2" title="page 2">[LAST]</a>';
425
        $this->assertEqual($expected, $this->pager->_printLastPage());
426
    }
427
    function testGetBackLink() {
428
        $img = '&laquo;';
429
        $options = array(
430
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
431
            'perPage'  => 5,
432
            'currentPage' => 2,
433
            'prevImg' => $img,
434
        );
435
        $this->pager = Pager::factory($options);
436
        $expected = '<a href="' . $_SERVER['PHP_SELF'] . '?pageID=1" title="previous page">'.$img.'</a>&nbsp;';
437
        $this->assertEqual($expected, $this->pager->_getBackLink());
438
    }
439
    function testGetNexLink() {
440
        $img = '&raquo;';
441
        $options = array(
442
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
443
            'perPage'  => 5,
444
            'currentPage' => 1,
445
            'nextImg' => $img,
446
        );
447
        $this->pager = Pager::factory($options);
448
        $expected = '&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?pageID=2" title="next page">'.$img.'</a>&nbsp;';
449
        $this->assertEqual($expected, $this->pager->_getNextLink());
450
    }
451
    function testHttpMethodAutoDetect() {
452
        $_POST['pageID'] = 3;
453
        $options = array(
454
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
455
            'perPage'  => 5,
456
        );
457
        $this->pager = Pager::factory($options);
458
        $this->assertEqual('POST', $this->pager->_httpMethod);
459
 
460
        $options = array(
461
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
462
            'perPage'  => 5,
463
            'httpMethod' => 'GET',
464
        );
465
        $this->pager = Pager::factory($options);
466
        $this->assertEqual('GET', $this->pager->_httpMethod);
467
 
468
        unset($_POST['pageID']);
469
 
470
        $options = array(
471
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
472
            'perPage'  => 5,
473
            'httpMethod' => 'POST',
474
        );
475
        $this->pager = Pager::factory($options);
476
        $this->assertEqual('POST', $this->pager->_httpMethod);
477
 
478
        $options = array(
479
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
480
            'perPage'  => 5,
481
        );
482
        $this->pager = Pager::factory($options);
483
        $this->assertEqual('GET', $this->pager->_httpMethod);
484
    }
485
    function testAccesskey() {
486
        $options = array(
487
            'itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
488
            'perPage'  => 5,
489
            'accesskey' => true,
490
        );
491
        $this->pager = Pager::factory($options);
492
        $this->assertWantedPattern('/accesskey="\d"/i', $this->pager->links);
493
        //var_dump($this->pager->links);
494
    }
495
    function testIsEncoded() {
496
    //var_dump(urlencode('&#50504;&#45397;'));
497
        $test_strings_encoded = array(
498
            'encoded0' => '&#35797;',
499
            'encoded1' => '&#27979;&#35797;',
500
            'encoded2' => '&#50504;&#45397;',
501
            'encoded3' => '&#50504; &#45397;',
502
            'encoded4' => '&#50504;
503
&#45397;',
504
        );
505
        $test_strings_plain = array(
506
            'plain1' => '안녕',
507
            'plain2' => '더보기',
508
//          'plain3' => '이젠 전화도
509
//로 걸면 무료',
510
            'plain4' => 'abcde',    //not multibyte
511
            'plain5' => '&#abcfg;', //invalid hex-encoded char
512
            'plain5' => '&#50504; nasty &#45397;', //mixed plain/encoded text
513
        );
514
        foreach ($test_strings_encoded as $string) {
515
            //echo '<hr />'.str_replace('&', '&amp;', $string);
516
            $this->assertTrue($this->pager->_isEncoded($string));
517
        }
518
        foreach ($test_strings_plain as $string) {
519
            $this->assertFalse($this->pager->_isEncoded($string));
520
        }
521
    }
522
    function testGetOption() {
523
        $this->assertEqual(5, $this->pager->getOption('perPage'));
524
        $err = $this->pager->getOption('non_existent_option');
525
        $this->assertEqual(ERROR_PAGER_INVALID, $err->getCode());
526
    }
527
    function testGetOptions() {
528
        $options = $this->pager->getOptions();
529
        $this->assertTrue(is_array($options));
530
        $this->assertEqual(5, $options['perPage']);
531
    }
532
    function testSetOptionsAndBuild() {
533
        $options = array(
534
            'perPage'  => 2,
535
        );
536
        $this->pager->setOptions($options);
537
        $this->pager->build();
538
        $this->assertEqual(2, $this->pager->getOption('perPage'));
539
        $this->assertEqual(array(0=>1, 1=>2), $this->pager->getPageData());
540
        $this->assertEqual(array(2=>3, 3=>4), $this->pager->getPageData(2));
541
 
542
        $options = array(
543
            'currentPage' => 2,
544
            'append'   => false,
545
            'fileName' => 'myfile.%d.php',
546
        );
547
        $this->pager->setOptions($options);
548
        $this->pager->build();
549
        $expected = '<link rel="previous" href="'.$this->baseurl.'/myfile.1.php" title="previous page" />'."\n";
550
        $this->assertEqual($expected, $this->pager->_getPrevLinkTag());
551
    }
552
}
553
?>