From b1baca99f280570d0336b4d71ad1f9dca213a35b Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 27 Sep 2020 14:07:08 +0200 Subject: Convert legacy PHPUnit @expected* to new ->expect* Converted automatically using https://github.com/ArthurHoaro/convert-legacy-phpunit-expect --- tests/legacy/LegacyLinkDBTest.php | 11 ++++++----- tests/legacy/LegacyLinkFilterTest.php | 10 ++++++---- tests/legacy/LegacyUpdaterTest.php | 10 ++++++---- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'tests/legacy') diff --git a/tests/legacy/LegacyLinkDBTest.php b/tests/legacy/LegacyLinkDBTest.php index 92cf607c..819bc272 100644 --- a/tests/legacy/LegacyLinkDBTest.php +++ b/tests/legacy/LegacyLinkDBTest.php @@ -101,10 +101,11 @@ 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->expectExceptionMessageRegExp('/Error accessing "null"/'); + new LegacyLinkDB('null/store.db', false, false); } @@ -420,22 +421,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(''); } diff --git a/tests/legacy/LegacyLinkFilterTest.php b/tests/legacy/LegacyLinkFilterTest.php index 8223cc15..9db921a9 100644 --- a/tests/legacy/LegacyLinkFilterTest.php +++ b/tests/legacy/LegacyLinkFilterTest.php @@ -198,20 +198,22 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase /** * Use an invalid date format * @expectedException Exception - * @expectedExceptionMessageRegExp /Invalid date format/ */ public function testFilterInvalidDayWithChars() { + $this->expectExceptionMessageRegExp('/Invalid date format/'); + self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away'); } /** * Use an invalid date format * @expectedException Exception - * @expectedExceptionMessageRegExp /Invalid date format/ */ public function testFilterInvalidDayDigits() { + $this->expectExceptionMessageRegExp('/Invalid date format/'); + self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20'); } @@ -235,11 +237,11 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase /** * No link for this hash - * - * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException */ public function testFilterUnknownSmallHash() { + $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class); + self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah'); } diff --git a/tests/legacy/LegacyUpdaterTest.php b/tests/legacy/LegacyUpdaterTest.php index 9b693dcb..acfac530 100644 --- a/tests/legacy/LegacyUpdaterTest.php +++ b/tests/legacy/LegacyUpdaterTest.php @@ -82,10 +82,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase * Test errors in UpdaterUtils::write_updates_file(): empty updates file. * * @expectedException Exception - * @expectedExceptionMessageRegExp /Updates file path is not set(.*)/ */ public function testWriteEmptyUpdatesFile() { + $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/'); + UpdaterUtils::write_updates_file('', array('test')); } @@ -93,10 +94,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase * Test errors in UpdaterUtils::write_updates_file(): not writable updates file. * * @expectedException Exception - * @expectedExceptionMessageRegExp /Unable to write(.*)/ */ public function testWriteUpdatesFileNotWritable() { + $this->expectExceptionMessageRegExp('/Unable to write(.*)/'); + $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; touch($updatesFile); chmod($updatesFile, 0444); @@ -161,11 +163,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase /** * Test Update failed. - * - * @expectedException \Exception */ public function testUpdateFailed() { + $this->expectException(\Exception::class); + $updates = array( 'updateMethodDummy1', 'updateMethodDummy2', -- cgit v1.2.3