]>
Commit | Line | Data |
---|---|---|
6fc14d53 | 1 | <?php |
1a8ac737 A |
2 | |
3 | namespace Shaarli\Legacy; | |
4 | ||
5 | use PHPUnit\Framework\TestCase; | |
6fc14d53 A |
6 | |
7 | /** | |
8 | * Unit tests for Router | |
9 | */ | |
1a8ac737 | 10 | class LegacyRouterTest extends TestCase |
6fc14d53 A |
11 | { |
12 | /** | |
13 | * Test findPage: login page output. | |
14 | * Valid: page should be return. | |
15 | * | |
16 | * @return void | |
17 | */ | |
18 | public function testFindPageLoginValid() | |
19 | { | |
20 | $this->assertEquals( | |
1a8ac737 A |
21 | LegacyRouter::$PAGE_LOGIN, |
22 | LegacyRouter::findPage('do=login', array(), false) | |
6fc14d53 A |
23 | ); |
24 | ||
25 | $this->assertEquals( | |
1a8ac737 A |
26 | LegacyRouter::$PAGE_LOGIN, |
27 | LegacyRouter::findPage('do=login', array(), 1) | |
6fc14d53 A |
28 | ); |
29 | ||
30 | $this->assertEquals( | |
1a8ac737 A |
31 | LegacyRouter::$PAGE_LOGIN, |
32 | LegacyRouter::findPage('do=login&stuff', array(), false) | |
6fc14d53 A |
33 | ); |
34 | } | |
35 | ||
36 | /** | |
37 | * Test findPage: login page output. | |
38 | * Invalid: page shouldn't be return. | |
39 | * | |
40 | * @return void | |
41 | */ | |
42 | public function testFindPageLoginInvalid() | |
43 | { | |
44 | $this->assertNotEquals( | |
1a8ac737 A |
45 | LegacyRouter::$PAGE_LOGIN, |
46 | LegacyRouter::findPage('do=login', array(), true) | |
6fc14d53 A |
47 | ); |
48 | ||
49 | $this->assertNotEquals( | |
1a8ac737 A |
50 | LegacyRouter::$PAGE_LOGIN, |
51 | LegacyRouter::findPage('do=other', array(), false) | |
6fc14d53 A |
52 | ); |
53 | } | |
54 | ||
55 | /** | |
56 | * Test findPage: picwall page output. | |
57 | * Valid: page should be return. | |
58 | * | |
59 | * @return void | |
60 | */ | |
61 | public function testFindPagePicwallValid() | |
62 | { | |
63 | $this->assertEquals( | |
1a8ac737 A |
64 | LegacyRouter::$PAGE_PICWALL, |
65 | LegacyRouter::findPage('do=picwall', array(), false) | |
6fc14d53 A |
66 | ); |
67 | ||
68 | $this->assertEquals( | |
1a8ac737 A |
69 | LegacyRouter::$PAGE_PICWALL, |
70 | LegacyRouter::findPage('do=picwall', array(), true) | |
6fc14d53 A |
71 | ); |
72 | } | |
73 | ||
74 | /** | |
75 | * Test findPage: picwall page output. | |
76 | * Invalid: page shouldn't be return. | |
77 | * | |
78 | * @return void | |
79 | */ | |
80 | public function testFindPagePicwallInvalid() | |
81 | { | |
82 | $this->assertEquals( | |
1a8ac737 A |
83 | LegacyRouter::$PAGE_PICWALL, |
84 | LegacyRouter::findPage('do=picwall&stuff', array(), false) | |
6fc14d53 A |
85 | ); |
86 | ||
87 | $this->assertNotEquals( | |
1a8ac737 A |
88 | LegacyRouter::$PAGE_PICWALL, |
89 | LegacyRouter::findPage('do=other', array(), false) | |
6fc14d53 A |
90 | ); |
91 | } | |
92 | ||
93 | /** | |
94 | * Test findPage: tagcloud page output. | |
95 | * Valid: page should be return. | |
96 | * | |
97 | * @return void | |
98 | */ | |
99 | public function testFindPageTagcloudValid() | |
100 | { | |
101 | $this->assertEquals( | |
1a8ac737 A |
102 | LegacyRouter::$PAGE_TAGCLOUD, |
103 | LegacyRouter::findPage('do=tagcloud', array(), false) | |
6fc14d53 A |
104 | ); |
105 | ||
106 | $this->assertEquals( | |
1a8ac737 A |
107 | LegacyRouter::$PAGE_TAGCLOUD, |
108 | LegacyRouter::findPage('do=tagcloud', array(), true) | |
6fc14d53 A |
109 | ); |
110 | ||
111 | $this->assertEquals( | |
1a8ac737 A |
112 | LegacyRouter::$PAGE_TAGCLOUD, |
113 | LegacyRouter::findPage('do=tagcloud&stuff', array(), false) | |
6fc14d53 A |
114 | ); |
115 | } | |
116 | ||
117 | /** | |
118 | * Test findPage: tagcloud page output. | |
119 | * Invalid: page shouldn't be return. | |
120 | * | |
121 | * @return void | |
122 | */ | |
123 | public function testFindPageTagcloudInvalid() | |
124 | { | |
125 | $this->assertNotEquals( | |
1a8ac737 A |
126 | LegacyRouter::$PAGE_TAGCLOUD, |
127 | LegacyRouter::findPage('do=other', array(), false) | |
6fc14d53 A |
128 | ); |
129 | } | |
130 | ||
131 | /** | |
132 | * Test findPage: linklist page output. | |
133 | * Valid: page should be return. | |
134 | * | |
135 | * @return void | |
136 | */ | |
137 | public function testFindPageLinklistValid() | |
138 | { | |
139 | $this->assertEquals( | |
1a8ac737 A |
140 | LegacyRouter::$PAGE_LINKLIST, |
141 | LegacyRouter::findPage('', array(), true) | |
6fc14d53 A |
142 | ); |
143 | ||
144 | $this->assertEquals( | |
1a8ac737 A |
145 | LegacyRouter::$PAGE_LINKLIST, |
146 | LegacyRouter::findPage('whatever', array(), true) | |
6fc14d53 A |
147 | ); |
148 | ||
149 | $this->assertEquals( | |
1a8ac737 A |
150 | LegacyRouter::$PAGE_LINKLIST, |
151 | LegacyRouter::findPage('whatever', array(), false) | |
6fc14d53 A |
152 | ); |
153 | ||
154 | $this->assertEquals( | |
1a8ac737 A |
155 | LegacyRouter::$PAGE_LINKLIST, |
156 | LegacyRouter::findPage('do=tools', array(), false) | |
6fc14d53 A |
157 | ); |
158 | } | |
159 | ||
160 | /** | |
161 | * Test findPage: tools page output. | |
162 | * Valid: page should be return. | |
163 | * | |
164 | * @return void | |
165 | */ | |
166 | public function testFindPageToolsValid() | |
167 | { | |
168 | $this->assertEquals( | |
1a8ac737 A |
169 | LegacyRouter::$PAGE_TOOLS, |
170 | LegacyRouter::findPage('do=tools', array(), true) | |
6fc14d53 A |
171 | ); |
172 | ||
173 | $this->assertEquals( | |
1a8ac737 A |
174 | LegacyRouter::$PAGE_TOOLS, |
175 | LegacyRouter::findPage('do=tools&stuff', array(), true) | |
6fc14d53 A |
176 | ); |
177 | } | |
178 | ||
179 | /** | |
180 | * Test findPage: tools page output. | |
181 | * Invalid: page shouldn't be return. | |
182 | * | |
183 | * @return void | |
184 | */ | |
185 | public function testFindPageToolsInvalid() | |
186 | { | |
187 | $this->assertNotEquals( | |
1a8ac737 A |
188 | LegacyRouter::$PAGE_TOOLS, |
189 | LegacyRouter::findPage('do=tools', array(), 1) | |
6fc14d53 A |
190 | ); |
191 | ||
192 | $this->assertNotEquals( | |
1a8ac737 A |
193 | LegacyRouter::$PAGE_TOOLS, |
194 | LegacyRouter::findPage('do=tools', array(), false) | |
6fc14d53 A |
195 | ); |
196 | ||
197 | $this->assertNotEquals( | |
1a8ac737 A |
198 | LegacyRouter::$PAGE_TOOLS, |
199 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
200 | ); |
201 | } | |
202 | ||
203 | /** | |
204 | * Test findPage: changepasswd page output. | |
205 | * Valid: page should be return. | |
206 | * | |
207 | * @return void | |
208 | */ | |
209 | public function testFindPageChangepasswdValid() | |
210 | { | |
211 | $this->assertEquals( | |
1a8ac737 A |
212 | LegacyRouter::$PAGE_CHANGEPASSWORD, |
213 | LegacyRouter::findPage('do=changepasswd', array(), true) | |
6fc14d53 A |
214 | ); |
215 | $this->assertEquals( | |
1a8ac737 A |
216 | LegacyRouter::$PAGE_CHANGEPASSWORD, |
217 | LegacyRouter::findPage('do=changepasswd&stuff', array(), true) | |
6fc14d53 | 218 | ); |
6fc14d53 A |
219 | } |
220 | ||
221 | /** | |
222 | * Test findPage: changepasswd page output. | |
223 | * Invalid: page shouldn't be return. | |
224 | * | |
225 | * @return void | |
226 | */ | |
227 | public function testFindPageChangepasswdInvalid() | |
228 | { | |
229 | $this->assertNotEquals( | |
1a8ac737 A |
230 | LegacyRouter::$PAGE_CHANGEPASSWORD, |
231 | LegacyRouter::findPage('do=changepasswd', array(), 1) | |
6fc14d53 A |
232 | ); |
233 | ||
234 | $this->assertNotEquals( | |
1a8ac737 A |
235 | LegacyRouter::$PAGE_CHANGEPASSWORD, |
236 | LegacyRouter::findPage('do=changepasswd', array(), false) | |
6fc14d53 A |
237 | ); |
238 | ||
239 | $this->assertNotEquals( | |
1a8ac737 A |
240 | LegacyRouter::$PAGE_CHANGEPASSWORD, |
241 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
242 | ); |
243 | } | |
244 | /** | |
245 | * Test findPage: configure page output. | |
246 | * Valid: page should be return. | |
247 | * | |
248 | * @return void | |
249 | */ | |
250 | public function testFindPageConfigureValid() | |
251 | { | |
252 | $this->assertEquals( | |
1a8ac737 A |
253 | LegacyRouter::$PAGE_CONFIGURE, |
254 | LegacyRouter::findPage('do=configure', array(), true) | |
6fc14d53 A |
255 | ); |
256 | ||
257 | $this->assertEquals( | |
1a8ac737 A |
258 | LegacyRouter::$PAGE_CONFIGURE, |
259 | LegacyRouter::findPage('do=configure&stuff', array(), true) | |
6fc14d53 A |
260 | ); |
261 | } | |
262 | ||
263 | /** | |
264 | * Test findPage: configure page output. | |
265 | * Invalid: page shouldn't be return. | |
266 | * | |
267 | * @return void | |
268 | */ | |
269 | public function testFindPageConfigureInvalid() | |
270 | { | |
271 | $this->assertNotEquals( | |
1a8ac737 A |
272 | LegacyRouter::$PAGE_CONFIGURE, |
273 | LegacyRouter::findPage('do=configure', array(), 1) | |
6fc14d53 A |
274 | ); |
275 | ||
276 | $this->assertNotEquals( | |
1a8ac737 A |
277 | LegacyRouter::$PAGE_CONFIGURE, |
278 | LegacyRouter::findPage('do=configure', array(), false) | |
6fc14d53 A |
279 | ); |
280 | ||
281 | $this->assertNotEquals( | |
1a8ac737 A |
282 | LegacyRouter::$PAGE_CONFIGURE, |
283 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
284 | ); |
285 | } | |
286 | ||
287 | /** | |
288 | * Test findPage: changetag page output. | |
289 | * Valid: page should be return. | |
290 | * | |
291 | * @return void | |
292 | */ | |
293 | public function testFindPageChangetagValid() | |
294 | { | |
295 | $this->assertEquals( | |
1a8ac737 A |
296 | LegacyRouter::$PAGE_CHANGETAG, |
297 | LegacyRouter::findPage('do=changetag', array(), true) | |
6fc14d53 A |
298 | ); |
299 | ||
300 | $this->assertEquals( | |
1a8ac737 A |
301 | LegacyRouter::$PAGE_CHANGETAG, |
302 | LegacyRouter::findPage('do=changetag&stuff', array(), true) | |
6fc14d53 A |
303 | ); |
304 | } | |
305 | ||
306 | /** | |
307 | * Test findPage: changetag page output. | |
308 | * Invalid: page shouldn't be return. | |
309 | * | |
310 | * @return void | |
311 | */ | |
312 | public function testFindPageChangetagInvalid() | |
313 | { | |
314 | $this->assertNotEquals( | |
1a8ac737 A |
315 | LegacyRouter::$PAGE_CHANGETAG, |
316 | LegacyRouter::findPage('do=changetag', array(), 1) | |
6fc14d53 A |
317 | ); |
318 | ||
319 | $this->assertNotEquals( | |
1a8ac737 A |
320 | LegacyRouter::$PAGE_CHANGETAG, |
321 | LegacyRouter::findPage('do=changetag', array(), false) | |
6fc14d53 A |
322 | ); |
323 | ||
324 | $this->assertNotEquals( | |
1a8ac737 A |
325 | LegacyRouter::$PAGE_CHANGETAG, |
326 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
327 | ); |
328 | } | |
329 | ||
330 | /** | |
331 | * Test findPage: addlink page output. | |
332 | * Valid: page should be return. | |
333 | * | |
334 | * @return void | |
335 | */ | |
336 | public function testFindPageAddlinkValid() | |
337 | { | |
338 | $this->assertEquals( | |
1a8ac737 A |
339 | LegacyRouter::$PAGE_ADDLINK, |
340 | LegacyRouter::findPage('do=addlink', array(), true) | |
6fc14d53 A |
341 | ); |
342 | ||
343 | $this->assertEquals( | |
1a8ac737 A |
344 | LegacyRouter::$PAGE_ADDLINK, |
345 | LegacyRouter::findPage('do=addlink&stuff', array(), true) | |
6fc14d53 A |
346 | ); |
347 | } | |
348 | ||
349 | /** | |
350 | * Test findPage: addlink page output. | |
351 | * Invalid: page shouldn't be return. | |
352 | * | |
353 | * @return void | |
354 | */ | |
355 | public function testFindPageAddlinkInvalid() | |
356 | { | |
357 | $this->assertNotEquals( | |
1a8ac737 A |
358 | LegacyRouter::$PAGE_ADDLINK, |
359 | LegacyRouter::findPage('do=addlink', array(), 1) | |
6fc14d53 A |
360 | ); |
361 | ||
362 | $this->assertNotEquals( | |
1a8ac737 A |
363 | LegacyRouter::$PAGE_ADDLINK, |
364 | LegacyRouter::findPage('do=addlink', array(), false) | |
6fc14d53 A |
365 | ); |
366 | ||
367 | $this->assertNotEquals( | |
1a8ac737 A |
368 | LegacyRouter::$PAGE_ADDLINK, |
369 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
370 | ); |
371 | } | |
372 | ||
373 | /** | |
374 | * Test findPage: export page output. | |
375 | * Valid: page should be return. | |
376 | * | |
377 | * @return void | |
378 | */ | |
379 | public function testFindPageExportValid() | |
380 | { | |
381 | $this->assertEquals( | |
1a8ac737 A |
382 | LegacyRouter::$PAGE_EXPORT, |
383 | LegacyRouter::findPage('do=export', array(), true) | |
6fc14d53 A |
384 | ); |
385 | ||
386 | $this->assertEquals( | |
1a8ac737 A |
387 | LegacyRouter::$PAGE_EXPORT, |
388 | LegacyRouter::findPage('do=export&stuff', array(), true) | |
6fc14d53 A |
389 | ); |
390 | } | |
391 | ||
392 | /** | |
393 | * Test findPage: export page output. | |
394 | * Invalid: page shouldn't be return. | |
395 | * | |
396 | * @return void | |
397 | */ | |
398 | public function testFindPageExportInvalid() | |
399 | { | |
400 | $this->assertNotEquals( | |
1a8ac737 A |
401 | LegacyRouter::$PAGE_EXPORT, |
402 | LegacyRouter::findPage('do=export', array(), 1) | |
6fc14d53 A |
403 | ); |
404 | ||
405 | $this->assertNotEquals( | |
1a8ac737 A |
406 | LegacyRouter::$PAGE_EXPORT, |
407 | LegacyRouter::findPage('do=export', array(), false) | |
6fc14d53 A |
408 | ); |
409 | ||
410 | $this->assertNotEquals( | |
1a8ac737 A |
411 | LegacyRouter::$PAGE_EXPORT, |
412 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
413 | ); |
414 | } | |
415 | ||
416 | /** | |
417 | * Test findPage: import page output. | |
418 | * Valid: page should be return. | |
419 | * | |
420 | * @return void | |
421 | */ | |
422 | public function testFindPageImportValid() | |
423 | { | |
424 | $this->assertEquals( | |
1a8ac737 A |
425 | LegacyRouter::$PAGE_IMPORT, |
426 | LegacyRouter::findPage('do=import', array(), true) | |
6fc14d53 A |
427 | ); |
428 | ||
429 | $this->assertEquals( | |
1a8ac737 A |
430 | LegacyRouter::$PAGE_IMPORT, |
431 | LegacyRouter::findPage('do=import&stuff', array(), true) | |
6fc14d53 A |
432 | ); |
433 | } | |
434 | ||
435 | /** | |
436 | * Test findPage: import page output. | |
437 | * Invalid: page shouldn't be return. | |
438 | * | |
439 | * @return void | |
440 | */ | |
441 | public function testFindPageImportInvalid() | |
442 | { | |
443 | $this->assertNotEquals( | |
1a8ac737 A |
444 | LegacyRouter::$PAGE_IMPORT, |
445 | LegacyRouter::findPage('do=import', array(), 1) | |
6fc14d53 A |
446 | ); |
447 | ||
448 | $this->assertNotEquals( | |
1a8ac737 A |
449 | LegacyRouter::$PAGE_IMPORT, |
450 | LegacyRouter::findPage('do=import', array(), false) | |
6fc14d53 A |
451 | ); |
452 | ||
453 | $this->assertNotEquals( | |
1a8ac737 A |
454 | LegacyRouter::$PAGE_IMPORT, |
455 | LegacyRouter::findPage('do=other', array(), true) | |
6fc14d53 A |
456 | ); |
457 | } | |
458 | ||
459 | /** | |
460 | * Test findPage: editlink page output. | |
461 | * Valid: page should be return. | |
462 | * | |
463 | * @return void | |
464 | */ | |
465 | public function testFindPageEditlinkValid() | |
466 | { | |
467 | $this->assertEquals( | |
1a8ac737 A |
468 | LegacyRouter::$PAGE_EDITLINK, |
469 | LegacyRouter::findPage('whatever', array('edit_link' => 1), true) | |
6fc14d53 A |
470 | ); |
471 | ||
472 | $this->assertEquals( | |
1a8ac737 A |
473 | LegacyRouter::$PAGE_EDITLINK, |
474 | LegacyRouter::findPage('', array('edit_link' => 1), true) | |
6fc14d53 A |
475 | ); |
476 | ||
477 | ||
478 | $this->assertEquals( | |
1a8ac737 A |
479 | LegacyRouter::$PAGE_EDITLINK, |
480 | LegacyRouter::findPage('whatever', array('post' => 1), true) | |
6fc14d53 A |
481 | ); |
482 | ||
483 | $this->assertEquals( | |
1a8ac737 A |
484 | LegacyRouter::$PAGE_EDITLINK, |
485 | LegacyRouter::findPage('whatever', array('post' => 1, 'edit_link' => 1), true) | |
6fc14d53 A |
486 | ); |
487 | } | |
488 | ||
489 | /** | |
490 | * Test findPage: editlink page output. | |
491 | * Invalid: page shouldn't be return. | |
492 | * | |
493 | * @return void | |
494 | */ | |
495 | public function testFindPageEditlinkInvalid() | |
496 | { | |
497 | $this->assertNotEquals( | |
1a8ac737 A |
498 | LegacyRouter::$PAGE_EDITLINK, |
499 | LegacyRouter::findPage('whatever', array('edit_link' => 1), false) | |
6fc14d53 A |
500 | ); |
501 | ||
502 | $this->assertNotEquals( | |
1a8ac737 A |
503 | LegacyRouter::$PAGE_EDITLINK, |
504 | LegacyRouter::findPage('whatever', array('edit_link' => 1), 1) | |
6fc14d53 A |
505 | ); |
506 | ||
507 | $this->assertNotEquals( | |
1a8ac737 A |
508 | LegacyRouter::$PAGE_EDITLINK, |
509 | LegacyRouter::findPage('whatever', array(), true) | |
6fc14d53 A |
510 | ); |
511 | } | |
d06265fb | 512 | } |