3 namespace Shaarli\Legacy
;
5 use PHPUnit\Framework\TestCase
;
8 * Unit tests for Router
10 class LegacyRouterTest
extends TestCase
13 * Test findPage: login page output.
14 * Valid: page should be return.
18 public function testFindPageLoginValid()
21 LegacyRouter
::$PAGE_LOGIN,
22 LegacyRouter
::findPage('do=login', array(), false)
26 LegacyRouter
::$PAGE_LOGIN,
27 LegacyRouter
::findPage('do=login', array(), 1)
31 LegacyRouter
::$PAGE_LOGIN,
32 LegacyRouter
::findPage('do=login&stuff', array(), false)
37 * Test findPage: login page output.
38 * Invalid: page shouldn't be return.
42 public function testFindPageLoginInvalid()
44 $this->assertNotEquals(
45 LegacyRouter
::$PAGE_LOGIN,
46 LegacyRouter
::findPage('do=login', array(), true)
49 $this->assertNotEquals(
50 LegacyRouter
::$PAGE_LOGIN,
51 LegacyRouter
::findPage('do=other', array(), false)
56 * Test findPage: picwall page output.
57 * Valid: page should be return.
61 public function testFindPagePicwallValid()
64 LegacyRouter
::$PAGE_PICWALL,
65 LegacyRouter
::findPage('do=picwall', array(), false)
69 LegacyRouter
::$PAGE_PICWALL,
70 LegacyRouter
::findPage('do=picwall', array(), true)
75 * Test findPage: picwall page output.
76 * Invalid: page shouldn't be return.
80 public function testFindPagePicwallInvalid()
83 LegacyRouter
::$PAGE_PICWALL,
84 LegacyRouter
::findPage('do=picwall&stuff', array(), false)
87 $this->assertNotEquals(
88 LegacyRouter
::$PAGE_PICWALL,
89 LegacyRouter
::findPage('do=other', array(), false)
94 * Test findPage: tagcloud page output.
95 * Valid: page should be return.
99 public function testFindPageTagcloudValid()
102 LegacyRouter
::$PAGE_TAGCLOUD,
103 LegacyRouter
::findPage('do=tagcloud', array(), false)
107 LegacyRouter
::$PAGE_TAGCLOUD,
108 LegacyRouter
::findPage('do=tagcloud', array(), true)
112 LegacyRouter
::$PAGE_TAGCLOUD,
113 LegacyRouter
::findPage('do=tagcloud&stuff', array(), false)
118 * Test findPage: tagcloud page output.
119 * Invalid: page shouldn't be return.
123 public function testFindPageTagcloudInvalid()
125 $this->assertNotEquals(
126 LegacyRouter
::$PAGE_TAGCLOUD,
127 LegacyRouter
::findPage('do=other', array(), false)
132 * Test findPage: linklist page output.
133 * Valid: page should be return.
137 public function testFindPageLinklistValid()
140 LegacyRouter
::$PAGE_LINKLIST,
141 LegacyRouter
::findPage('', array(), true)
145 LegacyRouter
::$PAGE_LINKLIST,
146 LegacyRouter
::findPage('whatever', array(), true)
150 LegacyRouter
::$PAGE_LINKLIST,
151 LegacyRouter
::findPage('whatever', array(), false)
155 LegacyRouter
::$PAGE_LINKLIST,
156 LegacyRouter
::findPage('do=tools', array(), false)
161 * Test findPage: tools page output.
162 * Valid: page should be return.
166 public function testFindPageToolsValid()
169 LegacyRouter
::$PAGE_TOOLS,
170 LegacyRouter
::findPage('do=tools', array(), true)
174 LegacyRouter
::$PAGE_TOOLS,
175 LegacyRouter
::findPage('do=tools&stuff', array(), true)
180 * Test findPage: tools page output.
181 * Invalid: page shouldn't be return.
185 public function testFindPageToolsInvalid()
187 $this->assertNotEquals(
188 LegacyRouter
::$PAGE_TOOLS,
189 LegacyRouter
::findPage('do=tools', array(), 1)
192 $this->assertNotEquals(
193 LegacyRouter
::$PAGE_TOOLS,
194 LegacyRouter
::findPage('do=tools', array(), false)
197 $this->assertNotEquals(
198 LegacyRouter
::$PAGE_TOOLS,
199 LegacyRouter
::findPage('do=other', array(), true)
204 * Test findPage: changepasswd page output.
205 * Valid: page should be return.
209 public function testFindPageChangepasswdValid()
212 LegacyRouter
::$PAGE_CHANGEPASSWORD,
213 LegacyRouter
::findPage('do=changepasswd', array(), true)
216 LegacyRouter
::$PAGE_CHANGEPASSWORD,
217 LegacyRouter
::findPage('do=changepasswd&stuff', array(), true)
222 * Test findPage: changepasswd page output.
223 * Invalid: page shouldn't be return.
227 public function testFindPageChangepasswdInvalid()
229 $this->assertNotEquals(
230 LegacyRouter
::$PAGE_CHANGEPASSWORD,
231 LegacyRouter
::findPage('do=changepasswd', array(), 1)
234 $this->assertNotEquals(
235 LegacyRouter
::$PAGE_CHANGEPASSWORD,
236 LegacyRouter
::findPage('do=changepasswd', array(), false)
239 $this->assertNotEquals(
240 LegacyRouter
::$PAGE_CHANGEPASSWORD,
241 LegacyRouter
::findPage('do=other', array(), true)
245 * Test findPage: configure page output.
246 * Valid: page should be return.
250 public function testFindPageConfigureValid()
253 LegacyRouter
::$PAGE_CONFIGURE,
254 LegacyRouter
::findPage('do=configure', array(), true)
258 LegacyRouter
::$PAGE_CONFIGURE,
259 LegacyRouter
::findPage('do=configure&stuff', array(), true)
264 * Test findPage: configure page output.
265 * Invalid: page shouldn't be return.
269 public function testFindPageConfigureInvalid()
271 $this->assertNotEquals(
272 LegacyRouter
::$PAGE_CONFIGURE,
273 LegacyRouter
::findPage('do=configure', array(), 1)
276 $this->assertNotEquals(
277 LegacyRouter
::$PAGE_CONFIGURE,
278 LegacyRouter
::findPage('do=configure', array(), false)
281 $this->assertNotEquals(
282 LegacyRouter
::$PAGE_CONFIGURE,
283 LegacyRouter
::findPage('do=other', array(), true)
288 * Test findPage: changetag page output.
289 * Valid: page should be return.
293 public function testFindPageChangetagValid()
296 LegacyRouter
::$PAGE_CHANGETAG,
297 LegacyRouter
::findPage('do=changetag', array(), true)
301 LegacyRouter
::$PAGE_CHANGETAG,
302 LegacyRouter
::findPage('do=changetag&stuff', array(), true)
307 * Test findPage: changetag page output.
308 * Invalid: page shouldn't be return.
312 public function testFindPageChangetagInvalid()
314 $this->assertNotEquals(
315 LegacyRouter
::$PAGE_CHANGETAG,
316 LegacyRouter
::findPage('do=changetag', array(), 1)
319 $this->assertNotEquals(
320 LegacyRouter
::$PAGE_CHANGETAG,
321 LegacyRouter
::findPage('do=changetag', array(), false)
324 $this->assertNotEquals(
325 LegacyRouter
::$PAGE_CHANGETAG,
326 LegacyRouter
::findPage('do=other', array(), true)
331 * Test findPage: addlink page output.
332 * Valid: page should be return.
336 public function testFindPageAddlinkValid()
339 LegacyRouter
::$PAGE_ADDLINK,
340 LegacyRouter
::findPage('do=addlink', array(), true)
344 LegacyRouter
::$PAGE_ADDLINK,
345 LegacyRouter
::findPage('do=addlink&stuff', array(), true)
350 * Test findPage: addlink page output.
351 * Invalid: page shouldn't be return.
355 public function testFindPageAddlinkInvalid()
357 $this->assertNotEquals(
358 LegacyRouter
::$PAGE_ADDLINK,
359 LegacyRouter
::findPage('do=addlink', array(), 1)
362 $this->assertNotEquals(
363 LegacyRouter
::$PAGE_ADDLINK,
364 LegacyRouter
::findPage('do=addlink', array(), false)
367 $this->assertNotEquals(
368 LegacyRouter
::$PAGE_ADDLINK,
369 LegacyRouter
::findPage('do=other', array(), true)
374 * Test findPage: export page output.
375 * Valid: page should be return.
379 public function testFindPageExportValid()
382 LegacyRouter
::$PAGE_EXPORT,
383 LegacyRouter
::findPage('do=export', array(), true)
387 LegacyRouter
::$PAGE_EXPORT,
388 LegacyRouter
::findPage('do=export&stuff', array(), true)
393 * Test findPage: export page output.
394 * Invalid: page shouldn't be return.
398 public function testFindPageExportInvalid()
400 $this->assertNotEquals(
401 LegacyRouter
::$PAGE_EXPORT,
402 LegacyRouter
::findPage('do=export', array(), 1)
405 $this->assertNotEquals(
406 LegacyRouter
::$PAGE_EXPORT,
407 LegacyRouter
::findPage('do=export', array(), false)
410 $this->assertNotEquals(
411 LegacyRouter
::$PAGE_EXPORT,
412 LegacyRouter
::findPage('do=other', array(), true)
417 * Test findPage: import page output.
418 * Valid: page should be return.
422 public function testFindPageImportValid()
425 LegacyRouter
::$PAGE_IMPORT,
426 LegacyRouter
::findPage('do=import', array(), true)
430 LegacyRouter
::$PAGE_IMPORT,
431 LegacyRouter
::findPage('do=import&stuff', array(), true)
436 * Test findPage: import page output.
437 * Invalid: page shouldn't be return.
441 public function testFindPageImportInvalid()
443 $this->assertNotEquals(
444 LegacyRouter
::$PAGE_IMPORT,
445 LegacyRouter
::findPage('do=import', array(), 1)
448 $this->assertNotEquals(
449 LegacyRouter
::$PAGE_IMPORT,
450 LegacyRouter
::findPage('do=import', array(), false)
453 $this->assertNotEquals(
454 LegacyRouter
::$PAGE_IMPORT,
455 LegacyRouter
::findPage('do=other', array(), true)
460 * Test findPage: editlink page output.
461 * Valid: page should be return.
465 public function testFindPageEditlinkValid()
468 LegacyRouter
::$PAGE_EDITLINK,
469 LegacyRouter
::findPage('whatever', array('edit_link' => 1), true)
473 LegacyRouter
::$PAGE_EDITLINK,
474 LegacyRouter
::findPage('', array('edit_link' => 1), true)
479 LegacyRouter
::$PAGE_EDITLINK,
480 LegacyRouter
::findPage('whatever', array('post' => 1), true)
484 LegacyRouter
::$PAGE_EDITLINK,
485 LegacyRouter
::findPage('whatever', array('post' => 1, 'edit_link' => 1), true)
490 * Test findPage: editlink page output.
491 * Invalid: page shouldn't be return.
495 public function testFindPageEditlinkInvalid()
497 $this->assertNotEquals(
498 LegacyRouter
::$PAGE_EDITLINK,
499 LegacyRouter
::findPage('whatever', array('edit_link' => 1), false)
502 $this->assertNotEquals(
503 LegacyRouter
::$PAGE_EDITLINK,
504 LegacyRouter
::findPage('whatever', array('edit_link' => 1), 1)
507 $this->assertNotEquals(
508 LegacyRouter
::$PAGE_EDITLINK,
509 LegacyRouter
::findPage('whatever', array(), true)