diff options
Diffstat (limited to 'tests/legacy/LegacyLinkDBTest.php')
-rw-r--r-- | tests/legacy/LegacyLinkDBTest.php | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/tests/legacy/LegacyLinkDBTest.php b/tests/legacy/LegacyLinkDBTest.php index 17b2b0e6..5c3fd425 100644 --- a/tests/legacy/LegacyLinkDBTest.php +++ b/tests/legacy/LegacyLinkDBTest.php | |||
@@ -11,7 +11,6 @@ use ReflectionClass; | |||
11 | use Shaarli; | 11 | use Shaarli; |
12 | use Shaarli\Bookmark\Bookmark; | 12 | use Shaarli\Bookmark\Bookmark; |
13 | 13 | ||
14 | require_once 'application/feed/Cache.php'; | ||
15 | require_once 'application/Utils.php'; | 14 | require_once 'application/Utils.php'; |
16 | require_once 'tests/utils/ReferenceLinkDB.php'; | 15 | require_once 'tests/utils/ReferenceLinkDB.php'; |
17 | 16 | ||
@@ -19,7 +18,7 @@ require_once 'tests/utils/ReferenceLinkDB.php'; | |||
19 | /** | 18 | /** |
20 | * Unitary tests for LegacyLinkDBTest | 19 | * Unitary tests for LegacyLinkDBTest |
21 | */ | 20 | */ |
22 | class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | 21 | class LegacyLinkDBTest extends \Shaarli\TestCase |
23 | { | 22 | { |
24 | // datastore to test write operations | 23 | // datastore to test write operations |
25 | protected static $testDatastore = 'sandbox/datastore.php'; | 24 | protected static $testDatastore = 'sandbox/datastore.php'; |
@@ -53,7 +52,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
53 | * | 52 | * |
54 | * Resets test data for each test | 53 | * Resets test data for each test |
55 | */ | 54 | */ |
56 | protected function setUp() | 55 | protected function setUp(): void |
57 | { | 56 | { |
58 | if (file_exists(self::$testDatastore)) { | 57 | if (file_exists(self::$testDatastore)) { |
59 | unlink(self::$testDatastore); | 58 | unlink(self::$testDatastore); |
@@ -100,12 +99,12 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
100 | 99 | ||
101 | /** | 100 | /** |
102 | * Attempt to instantiate a LinkDB whereas the datastore is not writable | 101 | * Attempt to instantiate a LinkDB whereas the datastore is not writable |
103 | * | ||
104 | * @expectedException Shaarli\Exceptions\IOException | ||
105 | * @expectedExceptionMessageRegExp /Error accessing "null"/ | ||
106 | */ | 102 | */ |
107 | public function testConstructDatastoreNotWriteable() | 103 | public function testConstructDatastoreNotWriteable() |
108 | { | 104 | { |
105 | $this->expectException(\Shaarli\Exceptions\IOException::class); | ||
106 | $this->expectExceptionMessageRegExp('/Error accessing "null"/'); | ||
107 | |||
109 | new LegacyLinkDB('null/store.db', false, false); | 108 | new LegacyLinkDB('null/store.db', false, false); |
110 | } | 109 | } |
111 | 110 | ||
@@ -258,7 +257,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
258 | $link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/'); | 257 | $link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/'); |
259 | 258 | ||
260 | $this->assertNotEquals(false, $link); | 259 | $this->assertNotEquals(false, $link); |
261 | $this->assertContains( | 260 | $this->assertContainsPolyfill( |
262 | 'A free software media publishing platform', | 261 | 'A free software media publishing platform', |
263 | $link['description'] | 262 | $link['description'] |
264 | ); | 263 | ); |
@@ -297,6 +296,10 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
297 | // They need to be grouped with the first case found - order by date DESC: `sTuff`. | 296 | // They need to be grouped with the first case found - order by date DESC: `sTuff`. |
298 | 'sTuff' => 2, | 297 | 'sTuff' => 2, |
299 | 'ut' => 1, | 298 | 'ut' => 1, |
299 | 'assurance' => 1, | ||
300 | 'coding-style' => 1, | ||
301 | 'quality' => 1, | ||
302 | 'standards' => 1, | ||
300 | ), | 303 | ), |
301 | self::$publicLinkDB->linksCountPerTag() | 304 | self::$publicLinkDB->linksCountPerTag() |
302 | ); | 305 | ); |
@@ -325,6 +328,10 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
325 | 'tag3' => 1, | 328 | 'tag3' => 1, |
326 | 'tag4' => 1, | 329 | 'tag4' => 1, |
327 | 'ut' => 1, | 330 | 'ut' => 1, |
331 | 'assurance' => 1, | ||
332 | 'coding-style' => 1, | ||
333 | 'quality' => 1, | ||
334 | 'standards' => 1, | ||
328 | ), | 335 | ), |
329 | self::$privateLinkDB->linksCountPerTag() | 336 | self::$privateLinkDB->linksCountPerTag() |
330 | ); | 337 | ); |
@@ -421,22 +428,22 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
421 | 428 | ||
422 | /** | 429 | /** |
423 | * Test filterHash() with an invalid smallhash. | 430 | * Test filterHash() with an invalid smallhash. |
424 | * | ||
425 | * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException | ||
426 | */ | 431 | */ |
427 | public function testFilterHashInValid1() | 432 | public function testFilterHashInValid1() |
428 | { | 433 | { |
434 | $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class); | ||
435 | |||
429 | $request = 'blabla'; | 436 | $request = 'blabla'; |
430 | self::$publicLinkDB->filterHash($request); | 437 | self::$publicLinkDB->filterHash($request); |
431 | } | 438 | } |
432 | 439 | ||
433 | /** | 440 | /** |
434 | * Test filterHash() with an empty smallhash. | 441 | * Test filterHash() with an empty smallhash. |
435 | * | ||
436 | * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException | ||
437 | */ | 442 | */ |
438 | public function testFilterHashInValid() | 443 | public function testFilterHashInValid() |
439 | { | 444 | { |
445 | $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class); | ||
446 | |||
440 | self::$publicLinkDB->filterHash(''); | 447 | self::$publicLinkDB->filterHash(''); |
441 | } | 448 | } |
442 | 449 | ||
@@ -471,9 +478,9 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
471 | 478 | ||
472 | $res = $linkDB->renameTag('cartoon', 'Taz'); | 479 | $res = $linkDB->renameTag('cartoon', 'Taz'); |
473 | $this->assertEquals(3, count($res)); | 480 | $this->assertEquals(3, count($res)); |
474 | $this->assertContains(' Taz ', $linkDB[4]['tags']); | 481 | $this->assertContainsPolyfill(' Taz ', $linkDB[4]['tags']); |
475 | $this->assertContains(' Taz ', $linkDB[1]['tags']); | 482 | $this->assertContainsPolyfill(' Taz ', $linkDB[1]['tags']); |
476 | $this->assertContains(' Taz ', $linkDB[0]['tags']); | 483 | $this->assertContainsPolyfill(' Taz ', $linkDB[0]['tags']); |
477 | } | 484 | } |
478 | 485 | ||
479 | /** | 486 | /** |
@@ -513,7 +520,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
513 | 520 | ||
514 | $res = $linkDB->renameTag('cartoon', null); | 521 | $res = $linkDB->renameTag('cartoon', null); |
515 | $this->assertEquals(3, count($res)); | 522 | $this->assertEquals(3, count($res)); |
516 | $this->assertNotContains('cartoon', $linkDB[4]['tags']); | 523 | $this->assertNotContainsPolyfill('cartoon', $linkDB[4]['tags']); |
517 | } | 524 | } |
518 | 525 | ||
519 | /** | 526 | /** |
@@ -545,6 +552,10 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase | |||
545 | 'tag4' => 1, | 552 | 'tag4' => 1, |
546 | 'ut' => 1, | 553 | 'ut' => 1, |
547 | 'w3c' => 1, | 554 | 'w3c' => 1, |
555 | 'assurance' => 1, | ||
556 | 'coding-style' => 1, | ||
557 | 'quality' => 1, | ||
558 | 'standards' => 1, | ||
548 | ]; | 559 | ]; |
549 | $tags = self::$privateLinkDB->linksCountPerTag(); | 560 | $tags = self::$privateLinkDB->linksCountPerTag(); |
550 | 561 | ||