From f447edb73b1bcb52e86286467d3ec7b7bdc29948 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 29 Sep 2020 18:41:21 +0200 Subject: [PATCH] Fix missing @expectedException convertion --- tests/ApplicationUtilsTest.php | 6 +++--- tests/bookmark/BookmarkFileServiceTest.php | 3 +-- tests/bookmark/BookmarkFilterTest.php | 4 ++-- tests/legacy/LegacyLinkDBTest.php | 3 +-- tests/legacy/LegacyLinkFilterTest.php | 4 ++-- tests/legacy/LegacyUpdaterTest.php | 6 ++---- tests/netscape/BookmarkExportTest.php | 2 +- tests/updater/UpdaterTest.php | 6 ++---- 8 files changed, 14 insertions(+), 20 deletions(-) diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 7ad1d34c..a232b351 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -144,10 +144,10 @@ public function testCheckUpdateNewVersionUnavailable() /** * Test update checks - invalid Git branch - * @expectedException Exception */ public function testCheckUpdateInvalidGitBranch() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid branch selected for updates/'); ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable'); @@ -261,10 +261,10 @@ public function testCheckSupportedPHPVersion() /** * Check a unsupported PHP version - * @expectedException Exception */ public function testCheckSupportedPHPVersion51() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); @@ -272,10 +272,10 @@ public function testCheckSupportedPHPVersion51() /** * Check another unsupported PHP version - * @expectedException Exception */ public function testCheckSupportedPHPVersion52() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Your PHP version is obsolete/'); $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index 51e71a85..c399822b 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -637,11 +637,10 @@ public function testInitialize() */ /** * Attempt to instantiate a LinkDB whereas the datastore is not writable - * - * @expectedException Shaarli\Bookmark\Exception\NotWritableDataStoreException */ public function testConstructDatastoreNotWriteable() { + $this->expectException(\Shaarli\Bookmark\Exception\NotWritableDataStoreException::class); $this->expectExceptionMessageRegExp('#Couldn\'t load data from the data store file "null".*#'); $conf = new ConfigManager('tests/utils/config/configJson'); diff --git a/tests/bookmark/BookmarkFilterTest.php b/tests/bookmark/BookmarkFilterTest.php index 2f15cb3c..48c7f824 100644 --- a/tests/bookmark/BookmarkFilterTest.php +++ b/tests/bookmark/BookmarkFilterTest.php @@ -212,10 +212,10 @@ public function testFilterUnknownDay() /** * Use an invalid date format - * @expectedException Exception */ public function testFilterInvalidDayWithChars() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid date format/'); self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away'); @@ -223,10 +223,10 @@ public function testFilterInvalidDayWithChars() /** * Use an invalid date format - * @expectedException Exception */ public function testFilterInvalidDayDigits() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid date format/'); self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20'); diff --git a/tests/legacy/LegacyLinkDBTest.php b/tests/legacy/LegacyLinkDBTest.php index 66746dfc..df2cad62 100644 --- a/tests/legacy/LegacyLinkDBTest.php +++ b/tests/legacy/LegacyLinkDBTest.php @@ -99,11 +99,10 @@ public function testConstructLoggedOut() /** * Attempt to instantiate a LinkDB whereas the datastore is not writable - * - * @expectedException Shaarli\Exceptions\IOException */ public function testConstructDatastoreNotWriteable() { + $this->expectException(\Shaarli\Exceptions\IOException::class); $this->expectExceptionMessageRegExp('/Error accessing "null"/'); new LegacyLinkDB('null/store.db', false, false); diff --git a/tests/legacy/LegacyLinkFilterTest.php b/tests/legacy/LegacyLinkFilterTest.php index 82bc93d8..45d7754d 100644 --- a/tests/legacy/LegacyLinkFilterTest.php +++ b/tests/legacy/LegacyLinkFilterTest.php @@ -197,10 +197,10 @@ public function testFilterUnknownDay() /** * Use an invalid date format - * @expectedException Exception */ public function testFilterInvalidDayWithChars() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid date format/'); self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away'); @@ -208,10 +208,10 @@ public function testFilterInvalidDayWithChars() /** * Use an invalid date format - * @expectedException Exception */ public function testFilterInvalidDayDigits() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid date format/'); self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20'); diff --git a/tests/legacy/LegacyUpdaterTest.php b/tests/legacy/LegacyUpdaterTest.php index 0ddcb4a6..f7391b86 100644 --- a/tests/legacy/LegacyUpdaterTest.php +++ b/tests/legacy/LegacyUpdaterTest.php @@ -80,11 +80,10 @@ public function testReadWriteUpdatesFile() /** * Test errors in UpdaterUtils::write_updates_file(): empty updates file. - * - * @expectedException Exception */ public function testWriteEmptyUpdatesFile() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/'); UpdaterUtils::write_updates_file('', array('test')); @@ -92,11 +91,10 @@ public function testWriteEmptyUpdatesFile() /** * Test errors in UpdaterUtils::write_updates_file(): not writable updates file. - * - * @expectedException Exception */ public function testWriteUpdatesFileNotWritable() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Unable to write(.*)/'); $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php index adf62f4f..9b95ccc9 100644 --- a/tests/netscape/BookmarkExportTest.php +++ b/tests/netscape/BookmarkExportTest.php @@ -77,10 +77,10 @@ public function setUp(): void /** * Attempt to export an invalid link selection - * @expectedException Exception */ public function testFilterAndFormatInvalid() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Invalid export selection/'); $this->netscapeBookmarkUtils->filterAndFormat( diff --git a/tests/updater/UpdaterTest.php b/tests/updater/UpdaterTest.php index 73029e07..a6280b8c 100644 --- a/tests/updater/UpdaterTest.php +++ b/tests/updater/UpdaterTest.php @@ -87,11 +87,10 @@ public function testReadWriteUpdatesFile() /** * Test errors in UpdaterUtils::write_updates_file(): empty updates file. - * - * @expectedException Exception */ public function testWriteEmptyUpdatesFile() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/'); UpdaterUtils::write_updates_file('', array('test')); @@ -99,11 +98,10 @@ public function testWriteEmptyUpdatesFile() /** * Test errors in UpdaterUtils::write_updates_file(): not writable updates file. - * - * @expectedException Exception */ public function testWriteUpdatesFileNotWritable() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Unable to write(.*)/'); $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';