X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Flegacy%2FLegacyLinkDBTest.php;h=5c3fd425f968c856b31d1e76dc96c47666be55d7;hb=a4a59e183e565a6933925b3cb30fc8393639ac5a;hp=0884ad03ed2bd40837bc08ac4d1d60adb28820f6;hpb=a975d97a8da64864c3c49f1c54f571eb4ea5b81a;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/legacy/LegacyLinkDBTest.php b/tests/legacy/LegacyLinkDBTest.php index 0884ad03..5c3fd425 100644 --- a/tests/legacy/LegacyLinkDBTest.php +++ b/tests/legacy/LegacyLinkDBTest.php @@ -18,7 +18,7 @@ require_once 'tests/utils/ReferenceLinkDB.php'; /** * Unitary tests for LegacyLinkDBTest */ -class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase +class LegacyLinkDBTest extends \Shaarli\TestCase { // datastore to test write operations protected static $testDatastore = 'sandbox/datastore.php'; @@ -52,7 +52,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase * * Resets test data for each test */ - protected function setUp() + protected function setUp(): void { if (file_exists(self::$testDatastore)) { unlink(self::$testDatastore); @@ -99,12 +99,12 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase /** * Attempt to instantiate a LinkDB whereas the datastore is not writable - * - * @expectedException Shaarli\Exceptions\IOException - * @expectedExceptionMessageRegExp /Error accessing "null"/ */ public function testConstructDatastoreNotWriteable() { + $this->expectException(\Shaarli\Exceptions\IOException::class); + $this->expectExceptionMessageRegExp('/Error accessing "null"/'); + new LegacyLinkDB('null/store.db', false, false); } @@ -257,7 +257,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase $link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/'); $this->assertNotEquals(false, $link); - $this->assertContains( + $this->assertContainsPolyfill( 'A free software media publishing platform', $link['description'] ); @@ -296,6 +296,10 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase // They need to be grouped with the first case found - order by date DESC: `sTuff`. 'sTuff' => 2, 'ut' => 1, + 'assurance' => 1, + 'coding-style' => 1, + 'quality' => 1, + 'standards' => 1, ), self::$publicLinkDB->linksCountPerTag() ); @@ -324,6 +328,10 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase 'tag3' => 1, 'tag4' => 1, 'ut' => 1, + 'assurance' => 1, + 'coding-style' => 1, + 'quality' => 1, + 'standards' => 1, ), self::$privateLinkDB->linksCountPerTag() ); @@ -420,22 +428,22 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase /** * Test filterHash() with an invalid smallhash. - * - * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException */ public function testFilterHashInValid1() { + $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class); + $request = 'blabla'; self::$publicLinkDB->filterHash($request); } /** * Test filterHash() with an empty smallhash. - * - * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException */ public function testFilterHashInValid() { + $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class); + self::$publicLinkDB->filterHash(''); } @@ -470,9 +478,9 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase $res = $linkDB->renameTag('cartoon', 'Taz'); $this->assertEquals(3, count($res)); - $this->assertContains(' Taz ', $linkDB[4]['tags']); - $this->assertContains(' Taz ', $linkDB[1]['tags']); - $this->assertContains(' Taz ', $linkDB[0]['tags']); + $this->assertContainsPolyfill(' Taz ', $linkDB[4]['tags']); + $this->assertContainsPolyfill(' Taz ', $linkDB[1]['tags']); + $this->assertContainsPolyfill(' Taz ', $linkDB[0]['tags']); } /** @@ -512,7 +520,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase $res = $linkDB->renameTag('cartoon', null); $this->assertEquals(3, count($res)); - $this->assertNotContains('cartoon', $linkDB[4]['tags']); + $this->assertNotContainsPolyfill('cartoon', $linkDB[4]['tags']); } /** @@ -544,6 +552,10 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase 'tag4' => 1, 'ut' => 1, 'w3c' => 1, + 'assurance' => 1, + 'coding-style' => 1, + 'quality' => 1, + 'standards' => 1, ]; $tags = self::$privateLinkDB->linksCountPerTag();