aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'tests/legacy')
-rw-r--r--tests/legacy/LegacyControllerTest.php2
-rw-r--r--tests/legacy/LegacyLinkDBTest.php28
-rw-r--r--tests/legacy/LegacyLinkFilterTest.php18
-rw-r--r--tests/legacy/LegacyRouterTest.php512
-rw-r--r--tests/legacy/LegacyUpdaterTest.php24
5 files changed, 37 insertions, 547 deletions
diff --git a/tests/legacy/LegacyControllerTest.php b/tests/legacy/LegacyControllerTest.php
index 4e52f3e1..1a2549a3 100644
--- a/tests/legacy/LegacyControllerTest.php
+++ b/tests/legacy/LegacyControllerTest.php
@@ -4,8 +4,8 @@ declare(strict_types=1);
4 4
5namespace Shaarli\Legacy; 5namespace Shaarli\Legacy;
6 6
7use PHPUnit\Framework\TestCase;
8use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper; 7use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper;
8use Shaarli\TestCase;
9use Slim\Http\Request; 9use Slim\Http\Request;
10use Slim\Http\Response; 10use Slim\Http\Response;
11 11
diff --git a/tests/legacy/LegacyLinkDBTest.php b/tests/legacy/LegacyLinkDBTest.php
index 0884ad03..df2cad62 100644
--- a/tests/legacy/LegacyLinkDBTest.php
+++ b/tests/legacy/LegacyLinkDBTest.php
@@ -18,7 +18,7 @@ require_once 'tests/utils/ReferenceLinkDB.php';
18/** 18/**
19 * Unitary tests for LegacyLinkDBTest 19 * Unitary tests for LegacyLinkDBTest
20 */ 20 */
21class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase 21class LegacyLinkDBTest extends \Shaarli\TestCase
22{ 22{
23 // datastore to test write operations 23 // datastore to test write operations
24 protected static $testDatastore = 'sandbox/datastore.php'; 24 protected static $testDatastore = 'sandbox/datastore.php';
@@ -52,7 +52,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
52 * 52 *
53 * Resets test data for each test 53 * Resets test data for each test
54 */ 54 */
55 protected function setUp() 55 protected function setUp(): void
56 { 56 {
57 if (file_exists(self::$testDatastore)) { 57 if (file_exists(self::$testDatastore)) {
58 unlink(self::$testDatastore); 58 unlink(self::$testDatastore);
@@ -99,12 +99,12 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
99 99
100 /** 100 /**
101 * Attempt to instantiate a LinkDB whereas the datastore is not writable 101 * Attempt to instantiate a LinkDB whereas the datastore is not writable
102 *
103 * @expectedException Shaarli\Exceptions\IOException
104 * @expectedExceptionMessageRegExp /Error accessing "null"/
105 */ 102 */
106 public function testConstructDatastoreNotWriteable() 103 public function testConstructDatastoreNotWriteable()
107 { 104 {
105 $this->expectException(\Shaarli\Exceptions\IOException::class);
106 $this->expectExceptionMessageRegExp('/Error accessing "null"/');
107
108 new LegacyLinkDB('null/store.db', false, false); 108 new LegacyLinkDB('null/store.db', false, false);
109 } 109 }
110 110
@@ -257,7 +257,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
257 $link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/'); 257 $link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/');
258 258
259 $this->assertNotEquals(false, $link); 259 $this->assertNotEquals(false, $link);
260 $this->assertContains( 260 $this->assertContainsPolyfill(
261 'A free software media publishing platform', 261 'A free software media publishing platform',
262 $link['description'] 262 $link['description']
263 ); 263 );
@@ -420,22 +420,22 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
420 420
421 /** 421 /**
422 * Test filterHash() with an invalid smallhash. 422 * Test filterHash() with an invalid smallhash.
423 *
424 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
425 */ 423 */
426 public function testFilterHashInValid1() 424 public function testFilterHashInValid1()
427 { 425 {
426 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
427
428 $request = 'blabla'; 428 $request = 'blabla';
429 self::$publicLinkDB->filterHash($request); 429 self::$publicLinkDB->filterHash($request);
430 } 430 }
431 431
432 /** 432 /**
433 * Test filterHash() with an empty smallhash. 433 * Test filterHash() with an empty smallhash.
434 *
435 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
436 */ 434 */
437 public function testFilterHashInValid() 435 public function testFilterHashInValid()
438 { 436 {
437 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
438
439 self::$publicLinkDB->filterHash(''); 439 self::$publicLinkDB->filterHash('');
440 } 440 }
441 441
@@ -470,9 +470,9 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
470 470
471 $res = $linkDB->renameTag('cartoon', 'Taz'); 471 $res = $linkDB->renameTag('cartoon', 'Taz');
472 $this->assertEquals(3, count($res)); 472 $this->assertEquals(3, count($res));
473 $this->assertContains(' Taz ', $linkDB[4]['tags']); 473 $this->assertContainsPolyfill(' Taz ', $linkDB[4]['tags']);
474 $this->assertContains(' Taz ', $linkDB[1]['tags']); 474 $this->assertContainsPolyfill(' Taz ', $linkDB[1]['tags']);
475 $this->assertContains(' Taz ', $linkDB[0]['tags']); 475 $this->assertContainsPolyfill(' Taz ', $linkDB[0]['tags']);
476 } 476 }
477 477
478 /** 478 /**
@@ -512,7 +512,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
512 512
513 $res = $linkDB->renameTag('cartoon', null); 513 $res = $linkDB->renameTag('cartoon', null);
514 $this->assertEquals(3, count($res)); 514 $this->assertEquals(3, count($res));
515 $this->assertNotContains('cartoon', $linkDB[4]['tags']); 515 $this->assertNotContainsPolyfill('cartoon', $linkDB[4]['tags']);
516 } 516 }
517 517
518 /** 518 /**
diff --git a/tests/legacy/LegacyLinkFilterTest.php b/tests/legacy/LegacyLinkFilterTest.php
index ba9ec529..45d7754d 100644
--- a/tests/legacy/LegacyLinkFilterTest.php
+++ b/tests/legacy/LegacyLinkFilterTest.php
@@ -10,7 +10,7 @@ use Shaarli\Legacy\LegacyLinkFilter;
10/** 10/**
11 * Class LegacyLinkFilterTest. 11 * Class LegacyLinkFilterTest.
12 */ 12 */
13class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase 13class LegacyLinkFilterTest extends \Shaarli\TestCase
14{ 14{
15 /** 15 /**
16 * @var string Test datastore path. 16 * @var string Test datastore path.
@@ -34,7 +34,7 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
34 /** 34 /**
35 * Instantiate linkFilter with ReferenceLinkDB data. 35 * Instantiate linkFilter with ReferenceLinkDB data.
36 */ 36 */
37 public static function setUpBeforeClass() 37 public static function setUpBeforeClass(): void
38 { 38 {
39 self::$refDB = new ReferenceLinkDB(true); 39 self::$refDB = new ReferenceLinkDB(true);
40 self::$refDB->write(self::$testDatastore); 40 self::$refDB->write(self::$testDatastore);
@@ -197,21 +197,23 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
197 197
198 /** 198 /**
199 * Use an invalid date format 199 * Use an invalid date format
200 * @expectedException Exception
201 * @expectedExceptionMessageRegExp /Invalid date format/
202 */ 200 */
203 public function testFilterInvalidDayWithChars() 201 public function testFilterInvalidDayWithChars()
204 { 202 {
203 $this->expectException(\Exception::class);
204 $this->expectExceptionMessageRegExp('/Invalid date format/');
205
205 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away'); 206 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away');
206 } 207 }
207 208
208 /** 209 /**
209 * Use an invalid date format 210 * Use an invalid date format
210 * @expectedException Exception
211 * @expectedExceptionMessageRegExp /Invalid date format/
212 */ 211 */
213 public function testFilterInvalidDayDigits() 212 public function testFilterInvalidDayDigits()
214 { 213 {
214 $this->expectException(\Exception::class);
215 $this->expectExceptionMessageRegExp('/Invalid date format/');
216
215 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20'); 217 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20');
216 } 218 }
217 219
@@ -235,11 +237,11 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
235 237
236 /** 238 /**
237 * No link for this hash 239 * No link for this hash
238 *
239 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
240 */ 240 */
241 public function testFilterUnknownSmallHash() 241 public function testFilterUnknownSmallHash()
242 { 242 {
243 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
244
243 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah'); 245 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah');
244 } 246 }
245 247
diff --git a/tests/legacy/LegacyRouterTest.php b/tests/legacy/LegacyRouterTest.php
deleted file mode 100644
index c2019ca7..00000000
--- a/tests/legacy/LegacyRouterTest.php
+++ /dev/null
@@ -1,512 +0,0 @@
1<?php
2
3namespace Shaarli\Legacy;
4
5use PHPUnit\Framework\TestCase;
6
7/**
8 * Unit tests for Router
9 */
10class LegacyRouterTest extends TestCase
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(
21 LegacyRouter::$PAGE_LOGIN,
22 LegacyRouter::findPage('do=login', array(), false)
23 );
24
25 $this->assertEquals(
26 LegacyRouter::$PAGE_LOGIN,
27 LegacyRouter::findPage('do=login', array(), 1)
28 );
29
30 $this->assertEquals(
31 LegacyRouter::$PAGE_LOGIN,
32 LegacyRouter::findPage('do=login&stuff', array(), false)
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(
45 LegacyRouter::$PAGE_LOGIN,
46 LegacyRouter::findPage('do=login', array(), true)
47 );
48
49 $this->assertNotEquals(
50 LegacyRouter::$PAGE_LOGIN,
51 LegacyRouter::findPage('do=other', array(), false)
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(
64 LegacyRouter::$PAGE_PICWALL,
65 LegacyRouter::findPage('do=picwall', array(), false)
66 );
67
68 $this->assertEquals(
69 LegacyRouter::$PAGE_PICWALL,
70 LegacyRouter::findPage('do=picwall', array(), true)
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(
83 LegacyRouter::$PAGE_PICWALL,
84 LegacyRouter::findPage('do=picwall&stuff', array(), false)
85 );
86
87 $this->assertNotEquals(
88 LegacyRouter::$PAGE_PICWALL,
89 LegacyRouter::findPage('do=other', array(), false)
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(
102 LegacyRouter::$PAGE_TAGCLOUD,
103 LegacyRouter::findPage('do=tagcloud', array(), false)
104 );
105
106 $this->assertEquals(
107 LegacyRouter::$PAGE_TAGCLOUD,
108 LegacyRouter::findPage('do=tagcloud', array(), true)
109 );
110
111 $this->assertEquals(
112 LegacyRouter::$PAGE_TAGCLOUD,
113 LegacyRouter::findPage('do=tagcloud&stuff', array(), false)
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(
126 LegacyRouter::$PAGE_TAGCLOUD,
127 LegacyRouter::findPage('do=other', array(), false)
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(
140 LegacyRouter::$PAGE_LINKLIST,
141 LegacyRouter::findPage('', array(), true)
142 );
143
144 $this->assertEquals(
145 LegacyRouter::$PAGE_LINKLIST,
146 LegacyRouter::findPage('whatever', array(), true)
147 );
148
149 $this->assertEquals(
150 LegacyRouter::$PAGE_LINKLIST,
151 LegacyRouter::findPage('whatever', array(), false)
152 );
153
154 $this->assertEquals(
155 LegacyRouter::$PAGE_LINKLIST,
156 LegacyRouter::findPage('do=tools', array(), false)
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(
169 LegacyRouter::$PAGE_TOOLS,
170 LegacyRouter::findPage('do=tools', array(), true)
171 );
172
173 $this->assertEquals(
174 LegacyRouter::$PAGE_TOOLS,
175 LegacyRouter::findPage('do=tools&stuff', array(), true)
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(
188 LegacyRouter::$PAGE_TOOLS,
189 LegacyRouter::findPage('do=tools', array(), 1)
190 );
191
192 $this->assertNotEquals(
193 LegacyRouter::$PAGE_TOOLS,
194 LegacyRouter::findPage('do=tools', array(), false)
195 );
196
197 $this->assertNotEquals(
198 LegacyRouter::$PAGE_TOOLS,
199 LegacyRouter::findPage('do=other', array(), true)
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(
212 LegacyRouter::$PAGE_CHANGEPASSWORD,
213 LegacyRouter::findPage('do=changepasswd', array(), true)
214 );
215 $this->assertEquals(
216 LegacyRouter::$PAGE_CHANGEPASSWORD,
217 LegacyRouter::findPage('do=changepasswd&stuff', array(), true)
218 );
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(
230 LegacyRouter::$PAGE_CHANGEPASSWORD,
231 LegacyRouter::findPage('do=changepasswd', array(), 1)
232 );
233
234 $this->assertNotEquals(
235 LegacyRouter::$PAGE_CHANGEPASSWORD,
236 LegacyRouter::findPage('do=changepasswd', array(), false)
237 );
238
239 $this->assertNotEquals(
240 LegacyRouter::$PAGE_CHANGEPASSWORD,
241 LegacyRouter::findPage('do=other', array(), true)
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(
253 LegacyRouter::$PAGE_CONFIGURE,
254 LegacyRouter::findPage('do=configure', array(), true)
255 );
256
257 $this->assertEquals(
258 LegacyRouter::$PAGE_CONFIGURE,
259 LegacyRouter::findPage('do=configure&stuff', array(), true)
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(
272 LegacyRouter::$PAGE_CONFIGURE,
273 LegacyRouter::findPage('do=configure', array(), 1)
274 );
275
276 $this->assertNotEquals(
277 LegacyRouter::$PAGE_CONFIGURE,
278 LegacyRouter::findPage('do=configure', array(), false)
279 );
280
281 $this->assertNotEquals(
282 LegacyRouter::$PAGE_CONFIGURE,
283 LegacyRouter::findPage('do=other', array(), true)
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(
296 LegacyRouter::$PAGE_CHANGETAG,
297 LegacyRouter::findPage('do=changetag', array(), true)
298 );
299
300 $this->assertEquals(
301 LegacyRouter::$PAGE_CHANGETAG,
302 LegacyRouter::findPage('do=changetag&stuff', array(), true)
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(
315 LegacyRouter::$PAGE_CHANGETAG,
316 LegacyRouter::findPage('do=changetag', array(), 1)
317 );
318
319 $this->assertNotEquals(
320 LegacyRouter::$PAGE_CHANGETAG,
321 LegacyRouter::findPage('do=changetag', array(), false)
322 );
323
324 $this->assertNotEquals(
325 LegacyRouter::$PAGE_CHANGETAG,
326 LegacyRouter::findPage('do=other', array(), true)
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(
339 LegacyRouter::$PAGE_ADDLINK,
340 LegacyRouter::findPage('do=addlink', array(), true)
341 );
342
343 $this->assertEquals(
344 LegacyRouter::$PAGE_ADDLINK,
345 LegacyRouter::findPage('do=addlink&stuff', array(), true)
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(
358 LegacyRouter::$PAGE_ADDLINK,
359 LegacyRouter::findPage('do=addlink', array(), 1)
360 );
361
362 $this->assertNotEquals(
363 LegacyRouter::$PAGE_ADDLINK,
364 LegacyRouter::findPage('do=addlink', array(), false)
365 );
366
367 $this->assertNotEquals(
368 LegacyRouter::$PAGE_ADDLINK,
369 LegacyRouter::findPage('do=other', array(), true)
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(
382 LegacyRouter::$PAGE_EXPORT,
383 LegacyRouter::findPage('do=export', array(), true)
384 );
385
386 $this->assertEquals(
387 LegacyRouter::$PAGE_EXPORT,
388 LegacyRouter::findPage('do=export&stuff', array(), true)
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(
401 LegacyRouter::$PAGE_EXPORT,
402 LegacyRouter::findPage('do=export', array(), 1)
403 );
404
405 $this->assertNotEquals(
406 LegacyRouter::$PAGE_EXPORT,
407 LegacyRouter::findPage('do=export', array(), false)
408 );
409
410 $this->assertNotEquals(
411 LegacyRouter::$PAGE_EXPORT,
412 LegacyRouter::findPage('do=other', array(), true)
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(
425 LegacyRouter::$PAGE_IMPORT,
426 LegacyRouter::findPage('do=import', array(), true)
427 );
428
429 $this->assertEquals(
430 LegacyRouter::$PAGE_IMPORT,
431 LegacyRouter::findPage('do=import&stuff', array(), true)
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(
444 LegacyRouter::$PAGE_IMPORT,
445 LegacyRouter::findPage('do=import', array(), 1)
446 );
447
448 $this->assertNotEquals(
449 LegacyRouter::$PAGE_IMPORT,
450 LegacyRouter::findPage('do=import', array(), false)
451 );
452
453 $this->assertNotEquals(
454 LegacyRouter::$PAGE_IMPORT,
455 LegacyRouter::findPage('do=other', array(), true)
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(
468 LegacyRouter::$PAGE_EDITLINK,
469 LegacyRouter::findPage('whatever', array('edit_link' => 1), true)
470 );
471
472 $this->assertEquals(
473 LegacyRouter::$PAGE_EDITLINK,
474 LegacyRouter::findPage('', array('edit_link' => 1), true)
475 );
476
477
478 $this->assertEquals(
479 LegacyRouter::$PAGE_EDITLINK,
480 LegacyRouter::findPage('whatever', array('post' => 1), true)
481 );
482
483 $this->assertEquals(
484 LegacyRouter::$PAGE_EDITLINK,
485 LegacyRouter::findPage('whatever', array('post' => 1, 'edit_link' => 1), true)
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(
498 LegacyRouter::$PAGE_EDITLINK,
499 LegacyRouter::findPage('whatever', array('edit_link' => 1), false)
500 );
501
502 $this->assertNotEquals(
503 LegacyRouter::$PAGE_EDITLINK,
504 LegacyRouter::findPage('whatever', array('edit_link' => 1), 1)
505 );
506
507 $this->assertNotEquals(
508 LegacyRouter::$PAGE_EDITLINK,
509 LegacyRouter::findPage('whatever', array(), true)
510 );
511 }
512}
diff --git a/tests/legacy/LegacyUpdaterTest.php b/tests/legacy/LegacyUpdaterTest.php
index 7c429811..f7391b86 100644
--- a/tests/legacy/LegacyUpdaterTest.php
+++ b/tests/legacy/LegacyUpdaterTest.php
@@ -20,7 +20,7 @@ require_once 'inc/rain.tpl.class.php';
20 * Class UpdaterTest. 20 * Class UpdaterTest.
21 * Runs unit tests against the updater class. 21 * Runs unit tests against the updater class.
22 */ 22 */
23class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase 23class LegacyUpdaterTest extends \Shaarli\TestCase
24{ 24{
25 /** 25 /**
26 * @var string Path to test datastore. 26 * @var string Path to test datastore.
@@ -40,7 +40,7 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
40 /** 40 /**
41 * Executed before each test. 41 * Executed before each test.
42 */ 42 */
43 public function setUp() 43 protected function setUp(): void
44 { 44 {
45 copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); 45 copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
46 $this->conf = new ConfigManager(self::$configFile); 46 $this->conf = new ConfigManager(self::$configFile);
@@ -80,23 +80,23 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
80 80
81 /** 81 /**
82 * Test errors in UpdaterUtils::write_updates_file(): empty updates file. 82 * Test errors in UpdaterUtils::write_updates_file(): empty updates file.
83 *
84 * @expectedException Exception
85 * @expectedExceptionMessageRegExp /Updates file path is not set(.*)/
86 */ 83 */
87 public function testWriteEmptyUpdatesFile() 84 public function testWriteEmptyUpdatesFile()
88 { 85 {
86 $this->expectException(\Exception::class);
87 $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
88
89 UpdaterUtils::write_updates_file('', array('test')); 89 UpdaterUtils::write_updates_file('', array('test'));
90 } 90 }
91 91
92 /** 92 /**
93 * Test errors in UpdaterUtils::write_updates_file(): not writable updates file. 93 * Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
94 *
95 * @expectedException Exception
96 * @expectedExceptionMessageRegExp /Unable to write(.*)/
97 */ 94 */
98 public function testWriteUpdatesFileNotWritable() 95 public function testWriteUpdatesFileNotWritable()
99 { 96 {
97 $this->expectException(\Exception::class);
98 $this->expectExceptionMessageRegExp('/Unable to write(.*)/');
99
100 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; 100 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
101 touch($updatesFile); 101 touch($updatesFile);
102 chmod($updatesFile, 0444); 102 chmod($updatesFile, 0444);
@@ -161,11 +161,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
161 161
162 /** 162 /**
163 * Test Update failed. 163 * Test Update failed.
164 *
165 * @expectedException \Exception
166 */ 164 */
167 public function testUpdateFailed() 165 public function testUpdateFailed()
168 { 166 {
167 $this->expectException(\Exception::class);
168
169 $updates = array( 169 $updates = array(
170 'updateMethodDummy1', 170 'updateMethodDummy1',
171 'updateMethodDummy2', 171 'updateMethodDummy2',
@@ -723,7 +723,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
723 $this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode')); 723 $this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode'));
724 $this->assertEquals(125, $this->conf->get('thumbnails.width')); 724 $this->assertEquals(125, $this->conf->get('thumbnails.width'));
725 $this->assertEquals(90, $this->conf->get('thumbnails.height')); 725 $this->assertEquals(90, $this->conf->get('thumbnails.height'));
726 $this->assertContains('You have enabled or changed thumbnails', $_SESSION['warnings'][0]); 726 $this->assertContainsPolyfill('You have enabled or changed thumbnails', $_SESSION['warnings'][0]);
727 } 727 }
728 728
729 /** 729 /**
@@ -754,7 +754,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
754 if (isset($_SESSION['warnings'])) { 754 if (isset($_SESSION['warnings'])) {
755 unset($_SESSION['warnings']); 755 unset($_SESSION['warnings']);
756 } 756 }
757 757
758 $updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION); 758 $updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION);
759 $this->assertTrue($updater->updateMethodWebThumbnailer()); 759 $this->assertTrue($updater->updateMethodWebThumbnailer());
760 $this->assertFalse($this->conf->exists('thumbnail')); 760 $this->assertFalse($this->conf->exists('thumbnail'));