X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2Flegacy%2FLegacyLinkDBTest.php;h=df2cad62295594145843eac725bff46bec8068e3;hb=df25b28dcd3cde54d42c18a55a810daa82bf5727;hp=0884ad03ed2bd40837bc08ac4d1d60adb28820f6;hpb=a975d97a8da64864c3c49f1c54f571eb4ea5b81a;p=github%2Fshaarli%2FShaarli.git 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'; /** * 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'] ); @@ -420,22 +420,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 +470,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 +512,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']); } /**