7 require_once 'application/Router.php';
10 * Unit tests for Router
12 class RouterTest
extends PHPUnit_Framework_TestCase
15 * Test findPage: login page output.
16 * Valid: page should be return.
20 public function testFindPageLoginValid()
24 Router
::findPage('do=login', array(), false)
29 Router
::findPage('do=login', array(), 1)
34 Router
::findPage('do=login&stuff', array(), false)
39 * Test findPage: login page output.
40 * Invalid: page shouldn't be return.
44 public function testFindPageLoginInvalid()
46 $this->assertNotEquals(
48 Router
::findPage('do=login', array(), true)
51 $this->assertNotEquals(
53 Router
::findPage('do=other', array(), false)
58 * Test findPage: picwall page output.
59 * Valid: page should be return.
63 public function testFindPagePicwallValid()
66 Router
::$PAGE_PICWALL,
67 Router
::findPage('do=picwall', array(), false)
71 Router
::$PAGE_PICWALL,
72 Router
::findPage('do=picwall', array(), true)
77 * Test findPage: picwall page output.
78 * Invalid: page shouldn't be return.
82 public function testFindPagePicwallInvalid()
85 Router
::$PAGE_PICWALL,
86 Router
::findPage('do=picwall&stuff', array(), false)
89 $this->assertNotEquals(
90 Router
::$PAGE_PICWALL,
91 Router
::findPage('do=other', array(), false)
96 * Test findPage: tagcloud page output.
97 * Valid: page should be return.
101 public function testFindPageTagcloudValid()
104 Router
::$PAGE_TAGCLOUD,
105 Router
::findPage('do=tagcloud', array(), false)
109 Router
::$PAGE_TAGCLOUD,
110 Router
::findPage('do=tagcloud', array(), true)
114 Router
::$PAGE_TAGCLOUD,
115 Router
::findPage('do=tagcloud&stuff', array(), false)
120 * Test findPage: tagcloud page output.
121 * Invalid: page shouldn't be return.
125 public function testFindPageTagcloudInvalid()
127 $this->assertNotEquals(
128 Router
::$PAGE_TAGCLOUD,
129 Router
::findPage('do=other', array(), false)
134 * Test findPage: linklist page output.
135 * Valid: page should be return.
139 public function testFindPageLinklistValid()
142 Router
::$PAGE_LINKLIST,
143 Router
::findPage('', array(), true)
147 Router
::$PAGE_LINKLIST,
148 Router
::findPage('whatever', array(), true)
152 Router
::$PAGE_LINKLIST,
153 Router
::findPage('whatever', array(), false)
157 Router
::$PAGE_LINKLIST,
158 Router
::findPage('do=tools', array(), false)
163 * Test findPage: tools page output.
164 * Valid: page should be return.
168 public function testFindPageToolsValid()
172 Router
::findPage('do=tools', array(), true)
177 Router
::findPage('do=tools&stuff', array(), true)
182 * Test findPage: tools page output.
183 * Invalid: page shouldn't be return.
187 public function testFindPageToolsInvalid()
189 $this->assertNotEquals(
191 Router
::findPage('do=tools', array(), 1)
194 $this->assertNotEquals(
196 Router
::findPage('do=tools', array(), false)
199 $this->assertNotEquals(
201 Router
::findPage('do=other', array(), true)
206 * Test findPage: changepasswd page output.
207 * Valid: page should be return.
211 public function testFindPageChangepasswdValid()
214 Router
::$PAGE_CHANGEPASSWORD,
215 Router
::findPage('do=changepasswd', array(), true)
218 Router
::$PAGE_CHANGEPASSWORD,
219 Router
::findPage('do=changepasswd&stuff', array(), true)
225 * Test findPage: changepasswd page output.
226 * Invalid: page shouldn't be return.
230 public function testFindPageChangepasswdInvalid()
232 $this->assertNotEquals(
233 Router
::$PAGE_CHANGEPASSWORD,
234 Router
::findPage('do=changepasswd', array(), 1)
237 $this->assertNotEquals(
238 Router
::$PAGE_CHANGEPASSWORD,
239 Router
::findPage('do=changepasswd', array(), false)
242 $this->assertNotEquals(
243 Router
::$PAGE_CHANGEPASSWORD,
244 Router
::findPage('do=other', array(), true)
248 * Test findPage: configure page output.
249 * Valid: page should be return.
253 public function testFindPageConfigureValid()
256 Router
::$PAGE_CONFIGURE,
257 Router
::findPage('do=configure', array(), true)
261 Router
::$PAGE_CONFIGURE,
262 Router
::findPage('do=configure&stuff', array(), true)
267 * Test findPage: configure page output.
268 * Invalid: page shouldn't be return.
272 public function testFindPageConfigureInvalid()
274 $this->assertNotEquals(
275 Router
::$PAGE_CONFIGURE,
276 Router
::findPage('do=configure', array(), 1)
279 $this->assertNotEquals(
280 Router
::$PAGE_CONFIGURE,
281 Router
::findPage('do=configure', array(), false)
284 $this->assertNotEquals(
285 Router
::$PAGE_CONFIGURE,
286 Router
::findPage('do=other', array(), true)
291 * Test findPage: changetag page output.
292 * Valid: page should be return.
296 public function testFindPageChangetagValid()
299 Router
::$PAGE_CHANGETAG,
300 Router
::findPage('do=changetag', array(), true)
304 Router
::$PAGE_CHANGETAG,
305 Router
::findPage('do=changetag&stuff', array(), true)
310 * Test findPage: changetag page output.
311 * Invalid: page shouldn't be return.
315 public function testFindPageChangetagInvalid()
317 $this->assertNotEquals(
318 Router
::$PAGE_CHANGETAG,
319 Router
::findPage('do=changetag', array(), 1)
322 $this->assertNotEquals(
323 Router
::$PAGE_CHANGETAG,
324 Router
::findPage('do=changetag', array(), false)
327 $this->assertNotEquals(
328 Router
::$PAGE_CHANGETAG,
329 Router
::findPage('do=other', array(), true)
334 * Test findPage: addlink page output.
335 * Valid: page should be return.
339 public function testFindPageAddlinkValid()
342 Router
::$PAGE_ADDLINK,
343 Router
::findPage('do=addlink', array(), true)
347 Router
::$PAGE_ADDLINK,
348 Router
::findPage('do=addlink&stuff', array(), true)
353 * Test findPage: addlink page output.
354 * Invalid: page shouldn't be return.
358 public function testFindPageAddlinkInvalid()
360 $this->assertNotEquals(
361 Router
::$PAGE_ADDLINK,
362 Router
::findPage('do=addlink', array(), 1)
365 $this->assertNotEquals(
366 Router
::$PAGE_ADDLINK,
367 Router
::findPage('do=addlink', array(), false)
370 $this->assertNotEquals(
371 Router
::$PAGE_ADDLINK,
372 Router
::findPage('do=other', array(), true)
377 * Test findPage: export page output.
378 * Valid: page should be return.
382 public function testFindPageExportValid()
385 Router
::$PAGE_EXPORT,
386 Router
::findPage('do=export', array(), true)
390 Router
::$PAGE_EXPORT,
391 Router
::findPage('do=export&stuff', array(), true)
396 * Test findPage: export page output.
397 * Invalid: page shouldn't be return.
401 public function testFindPageExportInvalid()
403 $this->assertNotEquals(
404 Router
::$PAGE_EXPORT,
405 Router
::findPage('do=export', array(), 1)
408 $this->assertNotEquals(
409 Router
::$PAGE_EXPORT,
410 Router
::findPage('do=export', array(), false)
413 $this->assertNotEquals(
414 Router
::$PAGE_EXPORT,
415 Router
::findPage('do=other', array(), true)
420 * Test findPage: import page output.
421 * Valid: page should be return.
425 public function testFindPageImportValid()
428 Router
::$PAGE_IMPORT,
429 Router
::findPage('do=import', array(), true)
433 Router
::$PAGE_IMPORT,
434 Router
::findPage('do=import&stuff', array(), true)
439 * Test findPage: import page output.
440 * Invalid: page shouldn't be return.
444 public function testFindPageImportInvalid()
446 $this->assertNotEquals(
447 Router
::$PAGE_IMPORT,
448 Router
::findPage('do=import', array(), 1)
451 $this->assertNotEquals(
452 Router
::$PAGE_IMPORT,
453 Router
::findPage('do=import', array(), false)
456 $this->assertNotEquals(
457 Router
::$PAGE_IMPORT,
458 Router
::findPage('do=other', array(), true)
463 * Test findPage: editlink page output.
464 * Valid: page should be return.
468 public function testFindPageEditlinkValid()
471 Router
::$PAGE_EDITLINK,
472 Router
::findPage('whatever', array('edit_link' => 1), true)
476 Router
::$PAGE_EDITLINK,
477 Router
::findPage('', array('edit_link' => 1), true)
482 Router
::$PAGE_EDITLINK,
483 Router
::findPage('whatever', array('post' => 1), true)
487 Router
::$PAGE_EDITLINK,
488 Router
::findPage('whatever', array('post' => 1, 'edit_link' => 1), true)
493 * Test findPage: editlink page output.
494 * Invalid: page shouldn't be return.
498 public function testFindPageEditlinkInvalid()
500 $this->assertNotEquals(
501 Router
::$PAGE_EDITLINK,
502 Router
::findPage('whatever', array('edit_link' => 1), false)
505 $this->assertNotEquals(
506 Router
::$PAGE_EDITLINK,
507 Router
::findPage('whatever', array('edit_link' => 1), 1)
510 $this->assertNotEquals(
511 Router
::$PAGE_EDITLINK,
512 Router
::findPage('whatever', array(), true)