From fc47711887d4887b7faad43ebb80fda82415460b Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 12 Feb 2020 14:00:45 -0500 Subject: [PATCH] Upgrade to PHPUnit 8 (#1548) - Eliminate deprecated annotations and method calls. - Add required return types to standard methods. - Add php-cs-fixer rules to improve tests. - Add .gitignore support for new test result cache. - Fixed a few minor bugs/bad comments identified while upgrading. --- .gitignore | 29 ++-- composer.json | 2 +- composer.lock | 142 ++++++++++++------ .../src/VuFindTest/Unit/ILSDriverTestCase.php | 3 +- .../src/VuFindTest/Unit/MinkTestCase.php | 9 +- .../src/VuFindTest/Unit/MockContainerTest.php | 2 +- .../src/VuFindTest/Unit/UserCreationTrait.php | 7 +- .../src/VuFindTest/Auth/DatabaseTest.php | 43 ++++-- .../src/VuFindTest/Auth/ILSTest.php | 42 +++--- .../src/VuFindTest/Auth/ShibbolethTest.php | 28 ++-- .../VuFindTest/Connection/SolrAuthTest.php | 5 +- .../src/VuFindTest/Connection/SolrTest.php | 5 +- .../VuFindTest/Db/Table/ChangeTrackerTest.php | 5 +- .../VuFindTest/Mink/AccountActionsTest.php | 13 +- .../src/VuFindTest/Mink/AccountMenuTest.php | 13 +- .../src/VuFindTest/Mink/BulkTest.php | 8 +- .../VuFindTest/Mink/CallnumberBrowseTest.php | 9 +- .../src/VuFindTest/Mink/CartTest.php | 8 +- .../src/VuFindTest/Mink/ChoiceAuthTest.php | 11 +- .../src/VuFindTest/Mink/FavoritesTest.php | 13 +- .../src/VuFindTest/Mink/FeedbackTest.php | 5 +- .../src/VuFindTest/Mink/IlsActionsTest.php | 11 +- .../src/VuFindTest/Mink/LinkResolverTest.php | 5 +- .../src/VuFindTest/Mink/ListViewsTest.php | 13 +- .../src/VuFindTest/Mink/NextPrevNavTest.php | 2 +- .../src/VuFindTest/Mink/RecordActionsTest.php | 11 +- .../src/VuFindTest/Mink/SavedSearchesTest.php | 11 +- .../src/VuFindTest/Mink/SearchFacetsTest.php | 5 +- .../src/VuFindTest/Mink/VisualizationTest.php | 2 +- .../View/Helper/Root/ResultFeedTest.php | 5 +- .../src/VuFindTest/Auth/ChoiceAuthTest.php | 15 +- .../src/VuFindTest/Auth/DatabaseUnitTest.php | 30 ++-- .../VuFindTest/Auth/ILSAuthenticatorTest.php | 10 +- .../src/VuFindTest/Auth/LDAPTest.php | 18 ++- .../src/VuFindTest/Auth/ManagerTest.php | 30 ++-- .../src/VuFindTest/Auth/MultiAuthTest.php | 15 +- .../src/VuFindTest/Auth/PluginManagerTest.php | 5 +- .../src/VuFindTest/Auth/SIP2Test.php | 6 +- .../Autocomplete/PluginManagerTest.php | 5 +- .../src/VuFindTest/Autocomplete/TagTest.php | 5 +- .../unit-tests/src/VuFindTest/CartTest.php | 2 +- .../VuFindTest/Config/PluginFactoryTest.php | 11 +- .../Config/SearchSpecsReaderTest.php | 4 +- .../src/VuFindTest/Config/VersionTest.php | 5 +- .../Content/AuthorNotes/PluginManagerTest.php | 5 +- .../Content/Covers/PluginManagerTest.php | 5 +- .../Content/Excerpts/PluginManagerTest.php | 5 +- .../VuFindTest/Content/PluginManagerTest.php | 5 +- .../Content/Reviews/PluginManagerTest.php | 5 +- .../src/VuFindTest/Cookie/ContainerTest.php | 4 +- .../src/VuFindTest/Cover/LoaderTest.php | 5 +- .../VuFindTest/Db/Table/PluginManagerTest.php | 5 +- .../src/VuFindTest/Db/Table/UserListTest.php | 3 +- .../VuFindTest/DoiLinker/UnpaywallTest.php | 5 +- .../src/VuFindTest/Form/FormTest.php | 5 +- .../Hierarchy/Driver/PluginManagerTest.php | 5 +- .../TreeDataSource/PluginManagerTest.php | 5 +- .../TreeRenderer/PluginManagerTest.php | 5 +- .../Translator/Loader/ExtendedIniTest.php | 5 +- .../src/VuFindTest/ILS/Driver/AlephTest.php | 2 +- .../src/VuFindTest/ILS/Driver/AmicusTest.php | 2 +- .../src/VuFindTest/ILS/Driver/DAIATest.php | 2 +- .../src/VuFindTest/ILS/Driver/DemoTest.php | 2 +- .../VuFindTest/ILS/Driver/EvergreenTest.php | 2 +- .../src/VuFindTest/ILS/Driver/HorizonTest.php | 2 +- .../ILS/Driver/HorizonXMLAPITest.php | 2 +- .../VuFindTest/ILS/Driver/InnovativeTest.php | 2 +- .../src/VuFindTest/ILS/Driver/KohaTest.php | 2 +- .../ILS/Driver/MultiBackendTest.php | 3 +- .../VuFindTest/ILS/Driver/NewGenLibTest.php | 2 +- .../src/VuFindTest/ILS/Driver/NoILSTest.php | 2 +- .../src/VuFindTest/ILS/Driver/PAIATest.php | 2 +- .../ILS/Driver/PluginManagerTest.php | 5 +- .../src/VuFindTest/ILS/Driver/PolarisTest.php | 2 +- .../src/VuFindTest/ILS/Driver/SampleTest.php | 2 +- .../VuFindTest/ILS/Driver/SierraRestTest.php | 2 +- .../VuFindTest/ILS/Driver/SymphonyTest.php | 2 +- .../src/VuFindTest/ILS/Driver/UnicornTest.php | 2 +- .../src/VuFindTest/ILS/Driver/VirtuaTest.php | 2 +- .../ILS/Driver/VoyagerRestfulTest.php | 2 +- .../src/VuFindTest/ILS/Driver/VoyagerTest.php | 2 +- .../src/VuFindTest/ILS/Driver/XCNCIP2Test.php | 2 +- .../src/VuFindTest/Mailer/MailerTest.php | 35 +++-- .../src/VuFindTest/QRCode/LoaderTest.php | 5 +- .../Recommend/PluginManagerTest.php | 5 +- .../Recommend/RandomRecommendTest.php | 29 ++-- .../VuFindTest/Recommend/SideFacetsTest.php | 5 +- .../src/VuFindTest/Record/CacheTest.php | 2 +- .../src/VuFindTest/Record/LoaderTest.php | 5 +- .../RecordDriver/PluginManagerTest.php | 5 +- .../RecordTab/PluginManagerTest.php | 5 +- .../VuFindTest/Related/PluginManagerTest.php | 5 +- .../src/VuFindTest/Reserves/CsvReaderTest.php | 5 +- .../Resolver/Driver/PluginManagerTest.php | 5 +- .../PermissionProvider/PluginManagerTest.php | 5 +- .../src/VuFindTest/SMS/ClickatellTest.php | 17 ++- .../VuFindTest/Search/BackendManagerTest.php | 10 +- .../Search/Options/PluginManagerTest.php | 5 +- .../Search/Params/PluginManagerTest.php | 5 +- .../Search/Primo/OnCampusListenerTest.php | 2 +- .../Primo/PrimoPermissionHandlerTest.php | 7 +- .../Search/Results/PluginManagerTest.php | 5 +- .../Solr/ConditionalFilterListenerTest.php | 2 +- .../Solr/HierarchicalFacetHelperTest.php | 2 +- .../Search/Solr/MultiIndexListenerTest.php | 2 +- .../Search/Solr/SpellingProcessorTest.php | 5 +- .../src/VuFindTest/Session/FileTest.php | 4 +- .../VuFindTest/Session/PluginManagerTest.php | 5 +- .../unit-tests/src/VuFindTest/TagsTest.php | 2 +- .../VuFindTest/UrlShortener/DatabaseTest.php | 5 +- .../src/VuFindTest/UrlShortener/NoneTest.php | 5 +- .../View/Helper/Root/PermissionTest.php | 3 +- .../View/Helper/Root/RecordTest.php | 10 +- .../View/Helper/Root/SafeMoneyFormatTest.php | 4 +- .../View/Helper/Root/TranslateTest.php | 10 +- .../Backend/BrowZine/BackendTest.php | 5 +- .../Backend/BrowZine/QueryBuilderTest.php | 5 +- .../Response/RecordCollectionFactoryTest.php | 5 +- .../Response/RecordCollectionFactoryTest.php | 10 +- .../XML/RecordCollectionFactoryTest.php | 10 +- .../Backend/LibGuides/BackendTest.php | 8 +- .../Backend/LibGuides/QueryBuilderTest.php | 5 +- .../Response/RecordCollectionFactoryTest.php | 5 +- .../VuFindTest/Backend/Primo/BackendTest.php | 6 +- .../Backend/Primo/ConnectorTest.php | 5 +- .../Response/RecordCollectionFactoryTest.php | 10 +- .../VuFindTest/Backend/Solr/BackendTest.php | 30 ++-- .../VuFindTest/Backend/Solr/ConnectorTest.php | 24 +-- .../Backend/Solr/HandlerMapTest.php | 28 ++-- .../Json/RecordCollectionFactoryTest.php | 5 +- .../VuFindTest/Backend/Summon/BackendTest.php | 8 +- .../Response/RecordCollectionFactoryTest.php | 10 +- .../Backend/WorldCat/ConnectorTest.php | 3 +- .../XML/RecordCollectionFactoryTest.php | 10 +- .../src/VuFindTest/Query/QueryGroupTest.php | 5 +- .../src/VuFindTest/SearchServiceTest.php | 65 ++++---- .../src/VuFindTest/LessCompilerTest.php | 6 +- .../src/VuFindTest/ThemeCompilerTest.php | 6 +- .../src/VuFindTest/ThemeInfoTest.php | 7 +- tests/vufind.php_cs | 5 + 140 files changed, 742 insertions(+), 520 deletions(-) diff --git a/.gitignore b/.gitignore index 20cbba2092d..4f1a4bd06fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,19 @@ # GNU Emacs temporary files -.idea -.vscode -ChangeLog \#* .\#* +*~ + .php_cs_cache .vagrant .vscode/* -TAGS -*~ -/data/.languages /downloads +/solr/vendor /vendor +ChangeLog +TAGS composer.phar import/solrmarc.log* -/node_modules -/public/swagger-ui -/.vagrant -/import -/solr -/auth.json -/core -/lessphp_*.list -/data -/docker-compose.override.yml -/docker-env.override.yml -/.env -**/compiled.css -**/print.css \ No newline at end of file +lessphp_*.list +module/VuFind/tests/.phpunit.result.cache +node_modules +public/swagger-ui diff --git a/composer.json b/composer.json index a5a7b4e98d5..312d2ea8012 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,7 @@ "friendsofphp/php-cs-fixer": "2.16.1", "phploc/phploc": "4.0.1", "phpmd/phpmd": "2.8.1", - "phpunit/phpunit": "7.5.20", + "phpunit/phpunit": "8.5.2", "sebastian/phpcpd": "4.1.0", "squizlabs/php_codesniffer": "3.5.3", "dmore/chrome-mink-driver": "^2.7" diff --git a/composer.lock b/composer.lock index a60cd82973c..ae9973c5848 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "189c69b581c42a2c33d1bcbaaaceb82f", + "content-hash": "0b5d6a74f9943e8177e4ca831be9dc0b", "packages": [ { "name": "ahand/mobileesp", @@ -6424,40 +6424,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "6.1.4", + "version": "7.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", + "phpunit/php-token-stream": "^3.1.1", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", + "sebastian/environment": "^4.2.2", "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-xdebug": "^2.6.0" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -6483,7 +6483,7 @@ "testing", "xunit" ], - "time": "2018-10-31T16:06:48+00:00" + "time": "2019-11-20T13:55:58+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6676,53 +6676,52 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.20", + "version": "8.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" + "reference": "018b6ac3c8ab20916db85fa91bf6465acb64d1e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/018b6ac3c8ab20916db85fa91bf6465acb64d1e0", + "reference": "018b6ac3c8ab20916db85fa91bf6465acb64d1e0", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.1", + "doctrine/instantiator": "^1.2.0", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.2", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^7.0.7", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.2", + "sebastian/exporter": "^3.1.1", + "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", "sebastian/version": "^2.0.1" }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -6730,7 +6729,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.5-dev" + "dev-master": "8.5-dev" } }, "autoload": { @@ -6756,7 +6755,7 @@ "testing", "xunit" ], - "time": "2020-01-08T08:45:45+00:00" + "time": "2020-01-08T08:49:49+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -7088,23 +7087,26 @@ }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -7112,7 +7114,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -7135,7 +7137,7 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "time": "2019-02-01T05:30:01+00:00" }, { "name": "sebastian/object-enumerator", @@ -7375,6 +7377,52 @@ "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "time": "2018-10-04T04:07:39+00:00" }, + { + "name": "sebastian/type", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2019-07-02T08:10:15+00:00" + }, { "name": "sebastian/version", "version": "2.0.1", diff --git a/module/VuFind/src/VuFindTest/Unit/ILSDriverTestCase.php b/module/VuFind/src/VuFindTest/Unit/ILSDriverTestCase.php index ae243edeae1..596e9542ffc 100644 --- a/module/VuFind/src/VuFindTest/Unit/ILSDriverTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/ILSDriverTestCase.php @@ -51,10 +51,11 @@ abstract class ILSDriverTestCase extends TestCase * * @return void * - * @expectedException VuFind\Exception\ILS */ public function testMissingConfiguration() { + $this->expectException(\VuFind\Exception\ILS::class); + $this->driver->init(); } } diff --git a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php index 671fe354be6..df3025e5379 100644 --- a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php @@ -362,11 +362,12 @@ abstract class MinkTestCase extends DbTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } // Reset the modified configs list. @@ -378,7 +379,7 @@ abstract class MinkTestCase extends DbTestCase * * @return void */ - public function tearDown() + public function tearDown(): void { $this->stopMinkSession(); $this->restoreConfigs(); @@ -389,7 +390,7 @@ abstract class MinkTestCase extends DbTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { // No teardown actions at this time. } diff --git a/module/VuFind/src/VuFindTest/Unit/MockContainerTest.php b/module/VuFind/src/VuFindTest/Unit/MockContainerTest.php index 995f5b1073f..6d50e199750 100644 --- a/module/VuFind/src/VuFindTest/Unit/MockContainerTest.php +++ b/module/VuFind/src/VuFindTest/Unit/MockContainerTest.php @@ -52,7 +52,7 @@ abstract class MockContainerTest extends \PHPUnit\Framework\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->container = new MockContainer($this); } diff --git a/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php b/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php index 7e7477ccb72..7959b0c20a4 100644 --- a/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php +++ b/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php @@ -47,9 +47,9 @@ trait UserCreationTrait * Static setup support function to fail if users already exist in the database. * We want to ensure a clean state for each test! * - * @return mixed + * @return void */ - protected static function failIfUsersExist() + protected static function failIfUsersExist(): void { // If CI is not running, all tests were skipped, so no work is necessary: $test = new static(); // create instance of current class @@ -60,9 +60,10 @@ trait UserCreationTrait // on a real system -- it's only meant for the continuous integration server) $userTable = $test->getTable('User'); if (count($userTable->select()) > 0) { - return self::fail( + self::fail( 'Test cannot run with pre-existing user data!' ); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php index ce187cdeaab..02004a41bee 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php @@ -52,11 +52,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -64,11 +64,12 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } $this->auth = $this->getAuthManager()->get('Database'); } @@ -137,10 +138,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testCreationWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getAccountCreationRequest(['username' => '']); $this->auth->create($request); } @@ -150,10 +152,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testCreationWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getAccountCreationRequest(['password' => '']); $this->auth->create($request); } @@ -163,10 +166,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testCreationWithPasswordMismatch() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getAccountCreationRequest(['password2' => '']); $this->auth->create($request); } @@ -176,10 +180,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testCreationWithInvalidEmail() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getAccountCreationRequest(['email' => 'garbage']); $this->auth->create($request); } @@ -206,10 +211,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testCreationWithDuplicateUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getAccountCreationRequest(['email' => 'user2@test.com']); $this->auth->create($request); } @@ -219,10 +225,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testCreationWithDuplicateEmail() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getAccountCreationRequest(['username' => 'testuser2']); $this->auth->create($request); } @@ -232,10 +239,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => '']); $this->auth->authenticate($request); } @@ -245,10 +253,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => '']); $this->auth->authenticate($request); } @@ -258,10 +267,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithUnrecognizedUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => 'unknown']); $this->auth->authenticate($request); } @@ -271,10 +281,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBadPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => "' OR 1=1 LIMIT 1"]); $this->auth->authenticate($request); } @@ -296,7 +307,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers('testuser'); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php index d93d89382ee..acc429c582b 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php @@ -47,11 +47,11 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -59,11 +59,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -152,10 +153,11 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => '']); $this->getAuth()->authenticate($request); } @@ -165,10 +167,11 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => '']); $this->getAuth()->authenticate($request); } @@ -178,10 +181,11 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testBadLoginResponse() { + $this->expectException(\VuFind\Exception\Auth::class); + // VuFind requires the ILS driver to return a value in cat_username // by default -- if that is missing, we should fail. $response = []; @@ -217,11 +221,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage authentication_error_technical */ public function testLoginWithMissingCatId() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('authentication_error_technical'); + $response = [ 'cat_username' => 'testuser', 'cat_password' => 'testpass', 'email' => 'user@test.com' @@ -243,11 +248,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage Password cannot be blank */ public function testUpdateUserPasswordWithEmptyValue() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('Password cannot be blank'); + $patron = ['cat_username' => 'testuser']; $request = $this->getLoginRequest( [ @@ -264,11 +270,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage authentication_error_technical */ public function testUpdateUserPasswordWithoutLoggedInUser() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('authentication_error_technical'); + $request = $this->getLoginRequest( [ 'oldpwd' => 'foo', @@ -284,11 +291,12 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage Passwords do not match */ public function testUpdateUserPasswordWithMismatch() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('Passwords do not match'); + $request = $this->getLoginRequest( [ 'oldpwd' => 'foo', @@ -354,7 +362,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['1234', 'testuser']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php index d92f1398dcf..4affd469b96 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php @@ -46,11 +46,11 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -58,11 +58,12 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -138,10 +139,11 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -151,10 +153,11 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } @@ -164,10 +167,11 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithMissingAttributeValue() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->Shibboleth->userattribute_value_1); $this->getAuthObject($config)->authenticate($this->getLoginRequest()); @@ -178,10 +182,11 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithoutUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->Shibboleth->username); $this->getAuthObject($config)->authenticate($this->getLoginRequest()); @@ -192,10 +197,11 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithoutLoginSetting() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->Shibboleth->login); $this->getAuthObject($config)->getSessionInitiator('http://target'); @@ -231,7 +237,7 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers('testuser'); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrAuthTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrAuthTest.php index 640542685d1..0321cc19742 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrAuthTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrAuthTest.php @@ -45,11 +45,12 @@ class SolrAuthTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrTest.php index af6c4b71a71..6d375baae90 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Connection/SolrTest.php @@ -45,11 +45,12 @@ class SolrTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php index 55462d130e8..400ed4476e2 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php @@ -45,11 +45,12 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountActionsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountActionsTest.php index 01fefbb74d8..9ea461aa890 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountActionsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountActionsTest.php @@ -45,11 +45,11 @@ class AccountActionsTest extends \VuFindTest\Unit\MinkTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -57,11 +57,12 @@ class AccountActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -221,7 +222,7 @@ class AccountActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountMenuTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountMenuTest.php index 30c779077d5..d2d413ecc24 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountMenuTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AccountMenuTest.php @@ -46,11 +46,11 @@ class AccountMenuTest extends \VuFindTest\Unit\MinkTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -58,11 +58,12 @@ class AccountMenuTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } // Setup config $this->changeConfigs([ @@ -446,7 +447,7 @@ class AccountMenuTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BulkTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BulkTest.php index c27b0c9e8f4..6766c39c227 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BulkTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BulkTest.php @@ -47,11 +47,11 @@ class BulkTest extends \VuFindTest\Unit\MinkTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -290,7 +290,7 @@ class BulkTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers('username1'); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php index 97896df502f..5dc9de0a2e0 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php @@ -53,11 +53,12 @@ class CallnumberBrowseTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -99,9 +100,9 @@ class CallnumberBrowseTest extends \VuFindTest\Unit\MinkTestCase { $this->assertTrue(is_object($link)); $href = $link->getAttribute('href'); - $this->assertContains($type, $href); + $this->assertStringContainsString($type, $href); $this->assertNotEquals('', $link->getText()); - $this->assertContains($link->getText(), $href); + $this->assertStringContainsString($link->getText(), $href); } protected function setupMultipleCallnumbers() diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php index 60155c12a27..48efd44c722 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php @@ -47,11 +47,11 @@ class CartTest extends \VuFindTest\Unit\MinkTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -801,7 +801,7 @@ class CartTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers('username1'); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ChoiceAuthTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ChoiceAuthTest.php index 9cf1cdd90cc..b6575dc74c4 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ChoiceAuthTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ChoiceAuthTest.php @@ -47,9 +47,9 @@ class ChoiceAuthTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -57,11 +57,12 @@ class ChoiceAuthTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -181,7 +182,7 @@ class ChoiceAuthTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1', 'catuser']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php index 26e2767c2d0..61d9177dd9d 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php @@ -47,11 +47,11 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -59,11 +59,12 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -629,7 +630,7 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1', 'username2']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FeedbackTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FeedbackTest.php index 42e1df94789..4af18df2b1a 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FeedbackTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FeedbackTest.php @@ -48,11 +48,12 @@ class FeedbackTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php index d38774fccee..8e68d5fb8b1 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/IlsActionsTest.php @@ -50,9 +50,9 @@ class IlsActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -60,11 +60,12 @@ class IlsActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -566,7 +567,7 @@ class IlsActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1', 'username2']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/LinkResolverTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/LinkResolverTest.php index a188b4674c1..d60552654f4 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/LinkResolverTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/LinkResolverTest.php @@ -48,11 +48,12 @@ class LinkResolverTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ListViewsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ListViewsTest.php index 28260bc8075..37b9f30d1ee 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ListViewsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ListViewsTest.php @@ -47,11 +47,11 @@ class ListViewsTest extends \VuFindTest\Unit\MinkTestCase /** * Standard setup method. * - * @return mixed + * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -59,11 +59,12 @@ class ListViewsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -245,7 +246,7 @@ class ListViewsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/NextPrevNavTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/NextPrevNavTest.php index 8b33761f411..0d12af50602 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/NextPrevNavTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/NextPrevNavTest.php @@ -65,6 +65,6 @@ class NextPrevNavTest extends \VuFindTest\Unit\MinkTestCase $session->visit($this->getVuFindUrl() . "/Record/geo20001"); // should fail if exception is thrown - $this->assertContains("Test Publication 20001", $this->findCss($page, "div.media-body > h1[property=name]")->getText()); + $this->assertStringContainsString("Test Publication 20001", $this->findCss($page, "div.media-body > h3[property=name]")->getText()); } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordActionsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordActionsTest.php index 3835313dcb4..dca04a80d83 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordActionsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordActionsTest.php @@ -47,9 +47,9 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -57,11 +57,12 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -452,7 +453,7 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1', 'username2', 'emailmaniac']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SavedSearchesTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SavedSearchesTest.php index f63e4ddca41..d1423204d89 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SavedSearchesTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SavedSearchesTest.php @@ -47,9 +47,9 @@ class SavedSearchesTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { - return static::failIfUsersExist(); + static::failIfUsersExist(); } /** @@ -57,11 +57,12 @@ class SavedSearchesTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } @@ -263,7 +264,7 @@ class SavedSearchesTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { static::removeUsers(['username1', 'username2']); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php index e469283c2cc..3bc917c01ba 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchFacetsTest.php @@ -53,11 +53,12 @@ class SearchFacetsTest extends \VuFindTest\Unit\MinkTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/VisualizationTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/VisualizationTest.php index 88612304981..d0d1bfa977b 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/VisualizationTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/VisualizationTest.php @@ -68,6 +68,6 @@ class VisualizationTest extends \VuFindTest\Unit\MinkTestCase $text = $this->findCss($page, '#visualResults')->getText(); // Confirm that some content has been dynamically loaded into the // visualization area: - $this->assertContains('A - General Works', $text); + $this->assertStringContainsString('A - General Works', $text); } } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php index f5646150fda..2ef78a9997e 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php @@ -45,11 +45,12 @@ class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase * * @return void */ - public function setUp() + public function setUp(): void { // Give up if we're not running in CI: if (!$this->continuousIntegrationRunning()) { - return $this->markTestSkipped('Continuous integration not running.'); + $this->markTestSkipped('Continuous integration not running.'); + return; } } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php index b38066da576..74708d2df3f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php @@ -49,11 +49,12 @@ class ChoiceAuthTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \VuFind\Exception\Auth - * @expectedExceptionMessage One or more ChoiceAuth parameters are missing. */ public function testBadConfiguration() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('One or more ChoiceAuth parameters are missing.'); + $ca = new ChoiceAuth($this->getSessionContainer()); $ca->setConfig(new Config([])); } @@ -63,11 +64,12 @@ class ChoiceAuthTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Plugin manager missing. */ public function testMissingPluginManager() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Plugin manager missing.'); + $ca = new ChoiceAuth($this->getSessionContainer()); $ca->getPluginManager(); } @@ -179,11 +181,12 @@ class ChoiceAuthTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Illegal setting: foo */ public function testIllegalMethod() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Illegal setting: foo'); + $request = new Request(); $request->getQuery()->set('auth_method', 'foo'); $ca = $this->getChoiceAuth(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php index e2d2b85d3f3..8f82fb61dbc 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php @@ -47,11 +47,12 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage Username cannot be blank */ public function testEmptyCreateRequest() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('Username cannot be blank'); + $db = new Database(); $db->create($this->getRequest()); } @@ -61,11 +62,12 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage Password cannot be blank */ public function testEmptyPasswordCreateRequest() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('Password cannot be blank'); + $db = new Database(); $arr = $this->getCreateParams(); $arr['password'] = $arr['password2'] = ''; @@ -77,11 +79,12 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage Passwords do not match */ public function testMismatchedPasswordCreateRequest() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('Passwords do not match'); + $db = new Database(); $arr = $this->getCreateParams(); $arr['password2'] = 'bad'; @@ -93,11 +96,12 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage DB table manager missing. */ public function testCreateWithMissingTableManager() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('DB table manager missing.'); + $db = new Database(); $db->create($this->getRequest($this->getCreateParams())); } @@ -107,11 +111,12 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage That email address is already used */ public function testCreateDuplicateEmail() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('That email address is already used'); + // Fake services: $table = $this->getMockTable(['getByEmail', 'getByUsername']); $table->expects($this->once())->method('getByEmail') @@ -131,11 +136,12 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth - * @expectedExceptionMessage That username is already taken */ public function testCreateDuplicateUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('That username is already taken'); + // Fake services: $table = $this->getMockTable(['getByUsername']); $table->expects($this->any())->method('getByUsername') diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php index 77ea52b3e29..3f7cf1d80a6 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php @@ -83,11 +83,12 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\ILS - * @expectedExceptionMessage kaboom */ public function testNewCatalogFailureByException() { + $this->expectException(\VuFind\Exception\ILS::class); + $this->expectExceptionMessage('kaboom'); + $manager = $this->getMockManager(); $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->throwException(new \VuFind\Exception\ILS('kaboom'))); @@ -157,11 +158,12 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\ILS - * @expectedExceptionMessage kaboom */ public function testExceptionDuringStoredLoginAttempt() { + $this->expectException(\VuFind\Exception\ILS::class); + $this->expectExceptionMessage('kaboom'); + $user = $this->getMockUser(['__get', '__isset', 'clearCredentials', 'getCatPassword']); $user->expects($this->any())->method('__get')->with($this->equalTo('cat_username'))->will($this->returnValue('user')); $user->expects($this->any())->method('__isset')->with($this->equalTo('cat_username'))->will($this->returnValue(true)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php index 855ffe854b8..6d0ead39f37 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php @@ -81,10 +81,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithMissingHost() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->LDAP->host); $this->getAuthObject($config)->getConfig(); @@ -95,10 +96,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithMissingPort() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->LDAP->port); $this->getAuthObject($config)->getConfig(); @@ -109,10 +111,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithMissingBaseDN() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->LDAP->basedn); $this->getAuthObject($config)->getConfig(); @@ -123,10 +126,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithMissingUid() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->LDAP->username); $this->getAuthObject($config)->getConfig(); @@ -188,10 +192,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -201,10 +206,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php index ec66ea34409..30b85dc7ffa 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php @@ -200,11 +200,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Illegal authentication method: MultiILS */ public function testSwitchingFailure() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Illegal authentication method: MultiILS'); + $config = ['Authentication' => ['method' => 'ChoiceAuth']]; $manager = $this->getManager($config); $this->assertEquals('ChoiceAuth', $manager->getAuthMethod()); @@ -358,11 +359,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * Test CSRF failure (same setup as successful login, but minus token) * * @return void - * @expectedException \VuFind\Exception\Auth - * @expectedExceptionMessage authentication_error_technical */ public function testMissingCsrf() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('authentication_error_technical'); + $user = $this->getMockUser(); $request = $this->getMockRequest(); $pm = $this->getMockPluginManager(); @@ -374,11 +376,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * Test CSRF failure (same setup as successful login, but with bad token) * * @return void - * @expectedException \VuFind\Exception\Auth - * @expectedExceptionMessage authentication_error_technical */ public function testIncorrectCsrf() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('authentication_error_technical'); + $user = $this->getMockUser(); $request = $this->getMockRequest(); $pm = $this->getMockPluginManager(); @@ -392,11 +395,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \VuFind\Exception\PasswordSecurity - * @expectedExceptionMessage Boom */ public function testPasswordSecurityException() { + $this->expectException(\VuFind\Exception\PasswordSecurity::class); + $this->expectExceptionMessage('Boom'); + $e = new \VuFind\Exception\PasswordSecurity('Boom'); $request = $this->getMockRequest(); $pm = $this->getMockPluginManager(); @@ -412,11 +416,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \VuFind\Exception\Auth - * @expectedExceptionMessage Blam */ public function testAuthException() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('Blam'); + $e = new \VuFind\Exception\Auth('Blam'); $request = $this->getMockRequest(); $pm = $this->getMockPluginManager(); @@ -432,11 +437,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \VuFind\Exception\Auth - * @expectedExceptionMessage authentication_error_technical */ public function testUnanticipatedException() { + $this->expectException(\VuFind\Exception\Auth::class); + $this->expectExceptionMessage('authentication_error_technical'); + $e = new \Exception('It is normal to see this in the error log during testing...'); $request = $this->getMockRequest(); $pm = $this->getMockPluginManager(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php index 24d3f1a26c4..8fccaa13eaf 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php @@ -79,10 +79,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testWithMissingMethodOrder() { + $this->expectException(\VuFind\Exception\Auth::class); + $config = $this->getAuthConfig(); unset($config->MultiAuth->method_order); $this->getAuthObject($config)->getConfig(); @@ -111,10 +112,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\ServiceNotFoundException */ public function testLoginWithBadService() { + $this->expectException(\Zend\ServiceManager\Exception\ServiceNotFoundException::class); + $config = $this->getAuthConfig(); $config->MultiAuth->method_order = 'InappropriateService,Database'; @@ -129,10 +131,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException */ public function testLoginWithBadClass() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $config = $this->getAuthConfig(); $config->MultiAuth->method_order = get_class($this) . ',Database'; @@ -145,10 +148,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -158,10 +162,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/PluginManagerTest.php index e82670cbf90..106547e0a8a 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Auth\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Auth\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php index 47961b07b21..f1e1f133174 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php @@ -97,10 +97,11 @@ class SIP2Test extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankUsername() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -110,10 +111,11 @@ class SIP2Test extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\Auth */ public function testLoginWithBlankPassword() { + $this->expectException(\VuFind\Exception\Auth::class); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/PluginManagerTest.php index 24c3016e8fe..a9969abb1a7 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Autocomplete\AutocompleteInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Autocomplete\\AutocompleteInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php index 00dcc4af575..1b7ed9c4b9f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php @@ -45,11 +45,12 @@ class TagTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage DB table manager missing. */ public function testMissingDependency() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('DB table manager missing.'); + $tag = new Tag(); $tag->getSuggestions('foo'); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php index 756a517751c..88c53c6c024 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php @@ -52,7 +52,7 @@ class CartTest extends \PHPUnit\Framework\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->loader = $this->getMockBuilder(\VuFind\Record\Loader::class) ->setMethods([]) diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php index 0c5250109b3..b07963d00ec 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php @@ -67,7 +67,7 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { // Create test files: $parentPath = Locator::getLocalConfigPath('unit-test-parent.ini', null, true); @@ -120,7 +120,7 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->factory = new \VuFind\Config\PluginFactory(); } @@ -236,7 +236,7 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase * Test that the plugin factory omits the Parent_Config section from the * merged configuration. * - * @void + * @return void */ public function testParentConfigOmission() { @@ -252,10 +252,11 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\Config\Exception\RuntimeException */ public function testReadOnlyConfig() { + $this->expectException(\Zend\Config\Exception\RuntimeException::class); + if (self::$writeFailed) { $this->markTestSkipped('Could not write test configurations.'); } @@ -268,7 +269,7 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { // Clean up test files: array_map('unlink', self::$filesToDelete); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php index 1571d1990d8..ca4ebc48210 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php @@ -61,7 +61,7 @@ class SearchSpecsReaderTest extends \VuFindTest\Unit\TestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { // Create test files: $parentPath = Locator::getLocalConfigPath('top.yaml', null, true); @@ -188,7 +188,7 @@ class SearchSpecsReaderTest extends \VuFindTest\Unit\TestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { // Clean up test files: array_map('unlink', self::$filesToDelete); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/VersionTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/VersionTest.php index 12ef1994a0a..1ef2547b9cf 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/VersionTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/VersionTest.php @@ -60,11 +60,12 @@ class VersionTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Cannot load /will/never/exist/ever/ever/build.xml. */ public function testMissingFile() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Cannot load /will/never/exist/ever/ever/build.xml.'); + Version::getBuildVersion('/will/never/exist/ever/ever'); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/AuthorNotes/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/AuthorNotes/PluginManagerTest.php index 42fcd571553..e032ed4d809 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/AuthorNotes/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/AuthorNotes/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Content\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Content\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/PluginManagerTest.php index 1fa58849f10..36a92613b02 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Content\AbstractCover */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Content\\AbstractCover'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Excerpts/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Excerpts/PluginManagerTest.php index 3472a32850a..233d3e515e6 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Excerpts/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Excerpts/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Content\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Content\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/PluginManagerTest.php index 8d42bbe68df..35fe3b7ff79 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Content\Loader */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Content\\Loader'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Reviews/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Reviews/PluginManagerTest.php index 7bd4ea03659..580ef954b81 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Reviews/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Reviews/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Content\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Content\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php index c6ada1dd287..552870285ce 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php @@ -47,7 +47,7 @@ class ContainerTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setup() + public function setUp(): void { $this->container = new Container('test'); } @@ -57,7 +57,7 @@ class ContainerTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function tearDown() + public function tearDown(): void { foreach ($this->container->getAllValues() as $k => $v) { unset($this->container->$k); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php index 163f17835e3..7146a608274 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php @@ -54,11 +54,12 @@ class LoaderTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Could not load default fail image. */ public function testUtterFailure() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Could not load default fail image.'); + $theme = $this->getMockBuilder(\VuFindTheme\ThemeInfo::class) ->setConstructorArgs(['foo', 'bar'])->getMock(); $theme->expects($this->once())->method('findContainingTheme')->with($this->equalTo(['images/noCover2.gif']))->will($this->returnValue(false)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/PluginManagerTest.php index 529a1781056..73b6f28dbfb 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Db\Table\Gateway */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Db\\Table\\Gateway'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/UserListTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/UserListTest.php index 2eb49650aab..b185d07ecbf 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/UserListTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Db/Table/UserListTest.php @@ -46,10 +46,11 @@ class UserListTest extends \VuFindTest\Unit\DbTestCase * * @return void * - * @expectedException VuFind\Exception\LoginRequired */ public function testLoginRequiredToCreateList() { + $this->expectException(\VuFind\Exception\LoginRequired::class); + $table = $this->getTable('UserList'); $list = $table->getNew(false); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php index f04a453e305..1d6d1539a01 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/DoiLinker/UnpaywallTest.php @@ -47,11 +47,12 @@ class UnpaywallTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Missing configuration for Unpaywall DOI linker: unpaywall_email */ public function testConfigValidation() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Missing configuration for Unpaywall DOI linker: unpaywall_email'); + new Unpaywall(new \Zend\Config\Config([])); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Form/FormTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Form/FormTest.php index 0706f6ad9ae..036362b6ffe 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Form/FormTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Form/FormTest.php @@ -92,11 +92,12 @@ class FormTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\RecordMissing - * @expectedExceptionMessage Form 'foo' not found */ public function testUndefinedFormId() { + $this->expectException(\VuFind\Exception\RecordMissing::class); + $this->expectExceptionMessage('Form \'foo\' not found'); + $form = new Form(new YamlReader()); $form->setFormId('foo'); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/Driver/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/Driver/PluginManagerTest.php index c107beec867..934978b2b86 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/Driver/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/Driver/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Hierarchy\Driver\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Hierarchy\\Driver\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeDataSource/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeDataSource/PluginManagerTest.php index 49bd6222b0d..c51395ee0a3 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeDataSource/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeDataSource/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Hierarchy\TreeDataSource\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Hierarchy\\TreeDataSource\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeRenderer/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeRenderer/PluginManagerTest.php index d9d9db51281..193c7a6b673 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeRenderer/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Hierarchy/TreeRenderer/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Hierarchy\TreeRenderer\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Hierarchy\\TreeRenderer\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php index 25799d6672d..7bf0b35cf99 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php @@ -158,11 +158,12 @@ class ExtendedIniTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\I18n\Exception\InvalidArgumentException - * @expectedExceptionMessage Ini file 'en.ini' not found */ public function testMissingPathStack() { + $this->expectException(\Zend\I18n\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Ini file \'en.ini\' not found'); + $loader = new ExtendedIni(); $loader->load('en', null); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AlephTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AlephTest.php index 8126dff8e8a..05162d0ec9f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AlephTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AlephTest.php @@ -45,7 +45,7 @@ class AlephTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Aleph(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AmicusTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AmicusTest.php index 9d0555b006e..354f3921b60 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AmicusTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/AmicusTest.php @@ -45,7 +45,7 @@ class AmicusTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Amicus(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DAIATest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DAIATest.php index c1850ee7d63..c278d834495 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DAIATest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DAIATest.php @@ -141,7 +141,7 @@ class DAIATest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = $this->createConnector(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DemoTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DemoTest.php index 9f94c7867a8..e657a9749d8 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DemoTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/DemoTest.php @@ -52,7 +52,7 @@ class DemoTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $session = $this->getMockBuilder(\Zend\Session\Container::class) ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/EvergreenTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/EvergreenTest.php index 13a1f98a08a..4c17bfae12b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/EvergreenTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/EvergreenTest.php @@ -45,7 +45,7 @@ class EvergreenTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Evergreen(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonTest.php index 195293e333f..54ab0018fae 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonTest.php @@ -45,7 +45,7 @@ class HorizonTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Horizon(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonXMLAPITest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonXMLAPITest.php index 0f1dfba14a3..23eaf056b48 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonXMLAPITest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/HorizonXMLAPITest.php @@ -45,7 +45,7 @@ class HorizonXMLAPITest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new HorizonXMLAPI(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/InnovativeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/InnovativeTest.php index bf4f803cf02..a1632283629 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/InnovativeTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/InnovativeTest.php @@ -45,7 +45,7 @@ class InnovativeTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Innovative(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/KohaTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/KohaTest.php index af5838dc422..e1041df92bc 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/KohaTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/KohaTest.php @@ -45,7 +45,7 @@ class KohaTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Koha(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php index b24510e4e50..7b31f319ed9 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php @@ -49,10 +49,11 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\ILS */ public function testMissingConfiguration() { + $this->expectException(\VuFind\Exception\ILS::class); + $test = new MultiBackend( new \VuFind\Config\PluginManager($this->getServiceManager()), $this->getMockILSAuthenticator(), diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NewGenLibTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NewGenLibTest.php index e7951bedd69..c1ed90befbb 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NewGenLibTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NewGenLibTest.php @@ -45,7 +45,7 @@ class NewGenLibTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new NewGenLib(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php index 0e36604525e..066b9dc0e8c 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php @@ -59,7 +59,7 @@ class NoILSTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->loader = $this->getMockBuilder(\VuFind\Record\Loader::class) ->setConstructorArgs( diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PAIATest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PAIATest.php index 20e0e523d65..d2034039a46 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PAIATest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PAIATest.php @@ -339,7 +339,7 @@ class PAIATest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = $this->createConnector(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PluginManagerTest.php index 41b9397c0c8..c6d182feea2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\ILS\Driver\DriverInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\ILS\\Driver\\DriverInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PolarisTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PolarisTest.php index ea4c93d9e40..a4e2a38c451 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PolarisTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/PolarisTest.php @@ -45,7 +45,7 @@ class PolarisTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Polaris(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SampleTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SampleTest.php index c478eda1c11..d14a8f5e3c9 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SampleTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SampleTest.php @@ -52,7 +52,7 @@ class SampleTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Sample(); $this->driver->init(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SierraRestTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SierraRestTest.php index 32f962bba9d..e6312c8f598 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SierraRestTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SierraRestTest.php @@ -59,7 +59,7 @@ class SierraRestTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $sessionFactory = function ($namespace) { return new \Zend\Session\Container($namespace); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php index 88434bb9ce9..d3fccb9b59a 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php @@ -52,7 +52,7 @@ class SymphonyTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $loader = $this->getMockBuilder(\VuFind\Record\Loader::class) ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/UnicornTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/UnicornTest.php index e99608f905c..130a9640ff7 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/UnicornTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/UnicornTest.php @@ -45,7 +45,7 @@ class UnicornTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Unicorn(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VirtuaTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VirtuaTest.php index f63a8706011..842318df9b1 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VirtuaTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VirtuaTest.php @@ -45,7 +45,7 @@ class VirtuaTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Virtua(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerRestfulTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerRestfulTest.php index 7226c5c8da3..a2fbfdab5e4 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerRestfulTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerRestfulTest.php @@ -45,7 +45,7 @@ class VoyagerRestfulTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new VoyagerRestful(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerTest.php index 947c5c74b1a..7ba1c214aa3 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerTest.php @@ -45,7 +45,7 @@ class VoyagerTest extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new Voyager(new \VuFind\Date\Converter()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/XCNCIP2Test.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/XCNCIP2Test.php index 799088000b1..328cdb5cdf7 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/XCNCIP2Test.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/XCNCIP2Test.php @@ -45,7 +45,7 @@ class XCNCIP2Test extends \VuFindTest\Unit\ILSDriverTestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->driver = new XCNCIP2(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php index a5d49a5128b..e24d67222f3 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php @@ -238,11 +238,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Invalid Recipient Email Address */ public function testBadTo() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Invalid Recipient Email Address'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $mailer = new Mailer($transport); $mailer->send('bad@bad', 'from@example.com', 'subject', 'body'); @@ -253,11 +254,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Invalid Reply-To Email Address */ public function testBadReplyTo() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Invalid Reply-To Email Address'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $mailer = new Mailer($transport); $mailer->send( @@ -270,11 +272,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Invalid Recipient Email Address */ public function testEmptyTo() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Invalid Recipient Email Address'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $mailer = new Mailer($transport); $mailer->send('', 'from@example.com', 'subject', 'body'); @@ -285,11 +288,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Too Many Email Recipients */ public function testTooManyRecipients() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Too Many Email Recipients'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $mailer = new Mailer($transport); $mailer->send('one@test.com;two@test.com', 'from@example.com', 'subject', 'body'); @@ -300,11 +304,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Invalid Sender Email Address */ public function testBadFrom() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Invalid Sender Email Address'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $mailer = new Mailer($transport); $mailer->send('to@example.com', 'bad@bad', 'subject', 'body'); @@ -315,11 +320,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Invalid Sender Email Address */ public function testBadFromInAddressObject() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Invalid Sender Email Address'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $mailer = new Mailer($transport); $mailer->send('to@example.com', new Address('bad@bad'), 'subject', 'body'); @@ -330,11 +336,12 @@ class MailerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Boom */ public function testTransportException() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Boom'); + $transport = $this->createMock(\Zend\Mail\Transport\TransportInterface::class); $transport->expects($this->once())->method('send')->will($this->throwException(new \Exception('Boom'))); $mailer = new Mailer($transport); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php index 6277b28eb2d..32cd2b4d48e 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php @@ -54,11 +54,12 @@ class LoaderTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Could not load default fail image. */ public function testUtterFailure() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Could not load default fail image.'); + $theme = $this->getMockBuilder(\VuFindTheme\ThemeInfo::class) ->setConstructorArgs(['foo', 'bar'])->getMock(); $theme->expects($this->once())->method('findContainingTheme')->with($this->equalTo(['images/noQRCode.gif']))->will($this->returnValue(false)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/PluginManagerTest.php index f6113819add..c2bbb1c52d2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Recommend\RecommendInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Recommend\\RecommendInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php index c114544a7cc..22f1e3726e4 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php @@ -28,7 +28,6 @@ */ namespace VuFindTest\Recommend; -use PHPUnit\Framework\Assert; use VuFind\Recommend\RandomRecommend as Random; use VuFindTest\Unit\TestCase as TestCase; @@ -48,7 +47,7 @@ class RandomRecommendTest extends TestCase * * @return void */ - public function setup() + public function setUp(): void { $this->recommend = new Random( $this->createMock(\VuFindSearch\Service::class), @@ -66,22 +65,22 @@ class RandomRecommendTest extends TestCase //[backend]:[limit]:[display mode]:[random mode]:[minimumset]:[facet1]:[facetvalue1] $this->recommend->setConfig("SolrWeb:5:mixed:disregard:20:facet1:value1:facet2:value2"); $this->assertEquals( - "SolrWeb", Assert::readAttribute($this->recommend, 'backend') + "SolrWeb", $this->getProperty($this->recommend, 'backend') ); $this->assertEquals( - "5", Assert::readAttribute($this->recommend, 'limit') + "5", $this->getProperty($this->recommend, 'limit') ); $this->assertEquals( - "mixed", Assert::readAttribute($this->recommend, 'displayMode') + "mixed", $this->getProperty($this->recommend, 'displayMode') ); $this->assertEquals( - "disregard", Assert::readAttribute($this->recommend, 'mode') + "disregard", $this->getProperty($this->recommend, 'mode') ); $this->assertEquals( - "20", Assert::readAttribute($this->recommend, 'minimum') + "20", $this->getProperty($this->recommend, 'minimum') ); - $filters = Assert::readAttribute($this->recommend, 'filters'); - $this->assertInternalType("array", $filters); + $filters = $this->getProperty($this->recommend, 'filters'); + $this->assertIsArray($filters); $this->assertCount(2, $filters); $this->assertEquals("facet1:value1", $filters[0]); $this->assertEquals("facet2:value2", $filters[1]); @@ -97,22 +96,22 @@ class RandomRecommendTest extends TestCase //[backend]:[limit]:[display mode]:[random mode]:[minimumset]:[facet1]:[facetvalue1] $this->recommend->setConfig(''); $this->assertEquals( - "Solr", Assert::readAttribute($this->recommend, 'backend') + "Solr", $this->getProperty($this->recommend, 'backend') ); $this->assertEquals( - "10", Assert::readAttribute($this->recommend, 'limit') + "10", $this->getProperty($this->recommend, 'limit') ); $this->assertEquals( - "standard", Assert::readAttribute($this->recommend, 'displayMode') + "standard", $this->getProperty($this->recommend, 'displayMode') ); $this->assertEquals( - "retain", Assert::readAttribute($this->recommend, 'mode') + "retain", $this->getProperty($this->recommend, 'mode') ); $this->assertEquals( - "0", Assert::readAttribute($this->recommend, 'minimum') + "0", $this->getProperty($this->recommend, 'minimum') ); $this->assertEquals( - [], Assert::readAttribute($this->recommend, 'filters') + [], $this->getProperty($this->recommend, 'filters') ); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php index f8427d2b950..c9579dd5f71 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php @@ -77,11 +77,12 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage VuFind\Recommend\SideFacets: hierarchical facet helper unavailable */ public function testMissingHierarchicalFacetHelper() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('VuFind\\Recommend\\SideFacets: hierarchical facet helper unavailable'); + $configLoader = $this->getMockConfigLoader( [ 'Results' => [ diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/CacheTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/CacheTest.php index 3afbad93a91..ddc0686f64d 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/CacheTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/CacheTest.php @@ -52,7 +52,7 @@ class CacheTest extends TestCase * * @return void */ - protected function setUp() + protected function setUp(): void { $cache = $this->getRecordCache(); $this->recordTable = [ diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php index 6e61abdf37c..7aa5a44f3ec 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php @@ -54,11 +54,12 @@ class LoaderTest extends TestCase * * @return void * - * @expectedException VuFind\Exception\RecordMissing - * @expectedExceptionMessage Record Solr:test does not exist. */ public function testMissingRecord() { + $this->expectException(\VuFind\Exception\RecordMissing::class); + $this->expectExceptionMessage('Record Solr:test does not exist.'); + $collection = $this->getCollection([]); $service = $this->createMock(\VuFindSearch\Service::class); $service->expects($this->once())->method('retrieve') diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/PluginManagerTest.php index 77dd971ab6f..23ae0b2c2f1 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\RecordDriver\AbstractBase */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\RecordDriver\\AbstractBase'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordTab/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordTab/PluginManagerTest.php index dfe106bbe6a..71de0e2c854 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordTab/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordTab/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\RecordTab\TabInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\RecordTab\\TabInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Related/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Related/PluginManagerTest.php index 1da043032ec..affc0acdc1f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Related/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Related/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Related\RelatedInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Related\\RelatedInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php index 59e451a6982..2fbf8d2217f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php @@ -137,11 +137,12 @@ class CsvReaderTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Could not find valid data. Details: */ public function testEmptyFile() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Could not find valid data. Details:'); + $this->getReader('empty.csv')->getReserves(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Resolver/Driver/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Resolver/Driver/PluginManagerTest.php index 44369aced8f..d38cd537d6b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Resolver/Driver/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Resolver/Driver/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Resolver\Driver\DriverInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Resolver\\Driver\\DriverInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Role/PermissionProvider/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Role/PermissionProvider/PluginManagerTest.php index d56ae165f6b..a0029539c8e 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Role/PermissionProvider/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Role/PermissionProvider/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Role\PermissionProvider\PermissionProviderInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Role\\PermissionProvider\\PermissionProviderInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php index 33febe51c47..6dbd76adce6 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php @@ -45,7 +45,7 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { // Without SOAP functionality, we can't proceed: if (!function_exists('iconv')) { @@ -93,11 +93,12 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage badbadbad */ public function testUnexpectedResponse() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('badbadbad'); + $client = $this->getMockClient(); $expectedUri = 'https://api.clickatell.com/http/sendmsg?api_id=api_id&user=user&password=password&to=1234567890&text=hello'; $response = new \Zend\Http\Response(); @@ -115,11 +116,12 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Problem sending text. */ public function testFailureResponse() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Problem sending text.'); + $client = $this->getMockClient(); $expectedUri = 'https://api.clickatell.com/http/sendmsg?api_id=api_id&user=user&password=password&to=1234567890&text=hello'; $response = new \Zend\Http\Response(); @@ -136,11 +138,12 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFind\Exception\Mail - * @expectedExceptionMessage Foo */ public function testClientException() { + $this->expectException(\VuFind\Exception\Mail::class); + $this->expectExceptionMessage('Foo'); + $client = $this->getMockClient(); $expectedUri = 'https://api.clickatell.com/http/sendmsg?api_id=api_id&user=user&password=password&to=1234567890&text=hello'; $client->expects($this->once())->method('setMethod')->with($this->equalTo('GET'))->will($this->returnValue($client)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/BackendManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/BackendManagerTest.php index a12d93cdc5a..fa35d2f5b8c 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/BackendManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/BackendManagerTest.php @@ -49,11 +49,12 @@ class BackendManagerTest extends TestCase * * @return void * - * @expectedException UnexpectedValueException - * @expectedExceptionMessage Expected backend registry to return object */ public function testGetThrowsOnNonObject() { + $this->expectException(\UnexpectedValueException::class); + $this->expectExceptionMessage('Expected backend registry to return object'); + $registry = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface'); $registry->expects($this->once()) ->method('get') @@ -67,11 +68,12 @@ class BackendManagerTest extends TestCase * * @return void * - * @expectedException UnexpectedValueException - * @expectedExceptionMessage does not implement the expected interface */ public function testGetThrowsOnNonBackend() { + $this->expectException(\UnexpectedValueException::class); + $this->expectExceptionMessage('does not implement the expected interface'); + $registry = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface'); $registry->expects($this->once()) ->method('get') diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Options/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Options/PluginManagerTest.php index 4cd57405f2e..4fe0afb6c48 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Options/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Options/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Search\Base\Options */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Search\\Base\\Options'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Params/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Params/PluginManagerTest.php index e4621b55386..0e4783afa1a 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Params/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Params/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Search\Base\Params */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Search\\Base\\Params'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/OnCampusListenerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/OnCampusListenerTest.php index c187af11321..c65adb3c154 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/OnCampusListenerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/OnCampusListenerTest.php @@ -59,7 +59,7 @@ class OnCampusListenerTest extends TestCase * * @return void */ - protected function setup() + protected function setUp(): void { $connector = new Connector('http://example.org/', 'sample', 'none'); $this->backend = new Backend($connector); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/PrimoPermissionHandlerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/PrimoPermissionHandlerTest.php index 92cf6336c4c..da295191bb2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/PrimoPermissionHandlerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Primo/PrimoPermissionHandlerTest.php @@ -130,7 +130,7 @@ class PrimoPermissionHandlerTest extends TestCase * * @return void */ - protected function setup() + protected function setUp(): void { } @@ -140,11 +140,12 @@ class PrimoPermissionHandlerTest extends TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage No institutionCode found. */ public function testWithoutConfig() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('No institutionCode found.'); + new PrimoPermissionHandler(null); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Results/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Results/PluginManagerTest.php index 8ab15d6a4ce..1f38219a792 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Results/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Results/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Search\Base\Results */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Search\\Base\\Results'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/ConditionalFilterListenerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/ConditionalFilterListenerTest.php index dffe9fe5068..c96f63e20b7 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/ConditionalFilterListenerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/ConditionalFilterListenerTest.php @@ -77,7 +77,7 @@ class ConditionalFilterListenerTest extends TestCase * * @return void */ - protected function setup() + protected function setUp(): void { $handlermap = new HandlerMap(['select' => ['fallback' => true]]); $connector = new Connector('http://example.org/', $handlermap); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php index 4911c02966f..994db6ecd47 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php @@ -112,7 +112,7 @@ class HierarchicalFacetHelperTest extends TestCase * * @return void */ - protected function setup() + protected function setUp(): void { $this->helper = new HierarchicalFacetHelper(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php index 58e59a5d07e..d374ac20576 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php @@ -121,7 +121,7 @@ class MultiIndexListenerTest extends TestCase * * @return void */ - protected function setup() + protected function setUp(): void { $handlermap = new HandlerMap(['select' => ['fallback' => true]]); $connector = new Connector('http://example.org/', $handlermap); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php index 6c9e6303cd5..3f0a9dda9f7 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php @@ -466,11 +466,12 @@ class SpellingProcessorTest extends TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Unexpected suggestion format; spellcheck.extendedResults must be set to true. */ public function testDetectionOfMissingExtendedResultsSetting() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Unexpected suggestion format; spellcheck.extendedResults must be set to true.'); + $sp = new SpellingProcessor(new Config([])); $spelling = $this->getFixture('spell5'); $query = $this->getFixture('query5'); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Session/FileTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Session/FileTest.php index 1e51b0d01bf..e17248ca85b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Session/FileTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Session/FileTest.php @@ -52,7 +52,7 @@ class FileTest extends \VuFindTest\Unit\SessionHandlerTestCase * * @return void */ - public function setUp() + public function setUp(): void { $tempdir = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : DIRECTORY_SEPARATOR . 'tmp'; @@ -64,7 +64,7 @@ class FileTest extends \VuFindTest\Unit\SessionHandlerTestCase * * @return void */ - public function tearDown() + public function tearDown(): void { rmdir($this->path); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Session/PluginManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Session/PluginManagerTest.php index 99408faeaaa..bd4a942a7f3 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Session/PluginManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Session/PluginManagerTest.php @@ -58,11 +58,12 @@ class PluginManagerTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException Zend\ServiceManager\Exception\InvalidServiceException - * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Session\HandlerInterface */ public function testExpectedInterface() { + $this->expectException(\Zend\ServiceManager\Exception\InvalidServiceException::class); + $this->expectExceptionMessage('Plugin ArrayObject does not belong to VuFind\\Session\\HandlerInterface'); + $pm = new PluginManager( $this->createMock(\Interop\Container\ContainerInterface::class) ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php index 8d35f5a9666..2e1fc226489 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php @@ -50,7 +50,7 @@ class TagsTest extends \PHPUnit\Framework\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->parser = new \VuFind\Tags(); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/DatabaseTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/DatabaseTest.php index 43ea7065d21..b3a11234af0 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/DatabaseTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/DatabaseTest.php @@ -111,11 +111,12 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Shortlink could not be resolved: B */ public function testResolutionOfBadInput() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Shortlink could not be resolved: B'); + $table = $this->getMockTable(['select']); $mockResults = $this->getMockBuilder(\Zend\Db\ResultSet::class) ->setMethods(['count']) diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/NoneTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/NoneTest.php index 1b978f255e3..010ea7a6591 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/NoneTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/UrlShortener/NoneTest.php @@ -57,11 +57,12 @@ class NoneTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage UrlShortener None is unable to resolve shortlinks. */ public function testNoResolution() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('UrlShortener None is unable to resolve shortlinks.'); + $none = new None(); $none->resolve('foo'); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/PermissionTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/PermissionTest.php index b6e4a301ba0..77d9c909edb 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/PermissionTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/PermissionTest.php @@ -100,10 +100,11 @@ class PermissionTest extends \VuFindTest\Unit\ViewHelperTestCase * * @return void * - * @expectedException Zend\View\Exception\RuntimeException */ public function testTemplateDisplay() { + $this->expectException(\Zend\View\Exception\RuntimeException::class); + // Template does not exist, expect an exception, though $mockPmd = $this->getMockPmd( [ diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php index f9c64675644..4b390054ca1 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php @@ -46,11 +46,12 @@ class RecordTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException Zend\View\Exception\RuntimeException - * @expectedExceptionMessage Cannot find RecordDriver/AbstractBase/core.phtml template for class: VuFind\RecordDriver\SolrMarc */ public function testMissingTemplate() { + $this->expectException(\Zend\View\Exception\RuntimeException::class); + $this->expectExceptionMessage('Cannot find RecordDriver/AbstractBase/core.phtml template for class: VuFind\\RecordDriver\\SolrMarc'); + $record = $this->getRecord($this->loadRecordFixture('testbug1.json')); $record->getView()->resolver()->expects($this->at(0))->method('resolve') ->with($this->equalTo('RecordDriver/SolrMarc/core.phtml')) @@ -439,11 +440,12 @@ class RecordTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Invalid URL array. */ public function testGetLinkDetailsFailure() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Invalid URL array.'); + $driver = new \VuFindTest\RecordDriver\TestHarness(); $driver->setRawData( [ diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SafeMoneyFormatTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SafeMoneyFormatTest.php index a879de3f5cd..ca18f1f57e9 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SafeMoneyFormatTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SafeMoneyFormatTest.php @@ -52,7 +52,7 @@ class SafeMoneyFormatTest extends \PHPUnit\Framework\TestCase * * @return void */ - public function setUp() + public function setUp(): void { // store current default and set a value for consistency in testing $this->locale = setlocale(LC_MONETARY, 0); @@ -67,7 +67,7 @@ class SafeMoneyFormatTest extends \PHPUnit\Framework\TestCase * * @return void */ - public function tearDown() + public function tearDown(): void { // restore current default setlocale(LC_MONETARY, $this->locale); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/TranslateTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/TranslateTest.php index db2c99a5879..e8beecb5006 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/TranslateTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/TranslateTest.php @@ -60,11 +60,12 @@ class TranslateTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Unexpected value sent to translator! */ public function testTranslateWithEmptyArray() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Unexpected value sent to translator!'); + $translate = new Translate(); $translate->__invoke([]); } @@ -74,11 +75,12 @@ class TranslateTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Unexpected value sent to translator! */ public function testTranslateWithOverfilledArray() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Unexpected value sent to translator!'); + $translate = new Translate(); $translate->__invoke([1, 2, 3]); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/BackendTest.php index 30925a9b559..9e137d08b59 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/BackendTest.php @@ -53,11 +53,12 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage retrieve() not supported by BrowZine. */ public function testRetrieve() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('retrieve() not supported by BrowZine.'); + $conn = $this->getConnector(); $back = new Backend($conn, $this->getRCFactory()); $back->retrieve('foo'); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/QueryBuilderTest.php index 571b7ee3e47..f1961ba0489 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/QueryBuilderTest.php @@ -63,11 +63,12 @@ class QueryBuilderTest extends TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Query groups not supported */ public function testAdvanced() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Query groups not supported'); + $qb = new QueryBuilder(); $qb->build(new QueryGroup('AND', [])); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php index 17d2c81f0f3..28378543d41 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/BrowZine/Response/RecordCollectionFactoryTest.php @@ -60,11 +60,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testInvalidInput() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $fact = new RecordCollectionFactory(); $coll = $fact->factory('garbage'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionFactoryTest.php index 979587af306..9aea6cc4397 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionFactoryTest.php @@ -47,11 +47,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Record factory must be callable. */ public function testConstructorRequiresFactoryFunction() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Record factory must be callable.'); + $factory = new RecordCollectionFactory(null); } @@ -60,11 +61,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testFactoryRequiresArray() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $factory = new RecordCollectionFactory( function () { } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionFactoryTest.php index bca3ea77c1e..eea6d5a4d57 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionFactoryTest.php @@ -47,11 +47,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Record factory must be callable. */ public function testConstructorRequiresValidFactoryFunction() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Record factory must be callable.'); + $factory = new RecordCollectionFactory(12345); } @@ -60,11 +61,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testInvalidInput() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $fact = new RecordCollectionFactory( function () { } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php index ba33c125ce9..fd2d39d97b3 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php @@ -54,11 +54,12 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage retrieve() not supported by LibGuides. */ public function testRetrieve() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('retrieve() not supported by LibGuides.'); + $conn = $this->getConnector(); $back = new Backend($conn, $this->getRCFactory()); $back->retrieve('foo'); @@ -144,10 +145,11 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException */ public function testSearchWrapsLibGuidesException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php index e1ec7c1c2c2..719e3112b9a 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php @@ -63,11 +63,12 @@ class QueryBuilderTest extends TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Advanced search not supported. */ public function testAdvanced() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Advanced search not supported.'); + $qb = new QueryBuilder(); $qb->build(new QueryGroup('AND', [])); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php index 45ded837971..814dbe8452e 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php @@ -60,11 +60,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testInvalidInput() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $fact = new RecordCollectionFactory(); $coll = $fact->factory('garbage'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php index 205c71762c0..9f30aeb1b7d 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php @@ -133,10 +133,11 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException */ public function testSearchWrapsPrimoException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') @@ -150,10 +151,11 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException */ public function testRetrieveWrapsPrimoException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) ->method('getRecord') diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php index c2cd04ca7a3..1bff6c91b7f 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php @@ -125,11 +125,12 @@ class ConnectorTest extends TestCase * * @return void * - * @expectedException \Exception - * @expectedExceptionMessage Unauthorized access */ public function testErrorInSuccessfulResponse() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Unauthorized access'); + $conn = $this->createConnector('error-with-success-http'); $terms = [ ['index' => 'Title', 'lookfor' => 'dummy query'], diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionFactoryTest.php index 3c7443ae189..4e50e11ffa4 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionFactoryTest.php @@ -47,11 +47,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Record factory must be callable. */ public function testConstructorRequiresValidFactoryFunction() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Record factory must be callable.'); + $factory = new RecordCollectionFactory(12345); } @@ -60,11 +61,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testInvalidInput() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $fact = new RecordCollectionFactory(); $coll = $fact->factory('garbage'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php index 6518657b158..eeee821fb93 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php @@ -172,11 +172,12 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage JSON decoding error: 4 -- bad { */ public function testBadJson() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('JSON decoding error: 4 -- bad {'); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') @@ -190,11 +191,12 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid response writer type: xml */ public function testInjectResponseWriterThrownOnIncompabileResponseWriter() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid response writer type: xml'); + $conn = $this->getConnectorMock(); $back = new Backend($conn); $back->retrieve('foobar', new ParamBag(['wt' => ['xml']])); @@ -205,11 +207,12 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid named list implementation type: bad */ public function testInjectResponseWriterThrownOnIncompabileNamedListSetting() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid named list implementation type: bad'); + $conn = $this->getConnectorMock(); $back = new Backend($conn); $back->retrieve('foobar', new ParamBag(['json.nl' => ['bad']])); @@ -283,11 +286,12 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException - * @expectedExceptionMessage Alphabetic Browse index missing. */ public function testRefineAlphaBrowseException() { + $this->expectException(\VuFindSearch\Backend\Exception\RemoteErrorException::class); + $this->expectExceptionMessage('Alphabetic Browse index missing.'); + $this->runRefineExceptionCall('does not exist'); } @@ -296,11 +300,12 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException - * @expectedExceptionMessage Alphabetic Browse index missing. */ public function testRefineAlphaBrowseExceptionWithAltString() { + $this->expectException(\VuFindSearch\Backend\Exception\RemoteErrorException::class); + $this->expectExceptionMessage('Alphabetic Browse index missing.'); + $this->runRefineExceptionCall('couldn\'t find a browse index'); } @@ -309,11 +314,12 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException - * @expectedExceptionMessage not a browse error */ public function testRefineAlphaBrowseExceptionWithNonBrowseString() { + $this->expectException(\VuFindSearch\Backend\Exception\RemoteErrorException::class); + $this->expectExceptionMessage('not a browse error'); + $this->runRefineExceptionCall('not a browse error'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php index 915cb709a05..1c1e9dc7767 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php @@ -64,7 +64,7 @@ class ConnectorTest extends TestCase { $conn = $this->createConnector('single-record'); $resp = $conn->retrieve('id'); - $this->assertInternalType('string', $resp); + $this->assertIsString($resp); json_decode($resp, true); $this->assertEquals(\JSON_ERROR_NONE, json_last_error()); } @@ -78,7 +78,7 @@ class ConnectorTest extends TestCase { $conn = $this->createConnector('no-match'); $resp = $conn->retrieve('id'); - $this->assertInternalType('string', $resp); + $this->assertIsString($resp); } /** @@ -86,11 +86,12 @@ class ConnectorTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\RemoteErrorException - * @expectedExceptionCode 500 */ public function testInternalServerError() { + $this->expectException(\VuFindSearch\Backend\Exception\RemoteErrorException::class); + $this->expectExceptionCode(500); + $conn = $this->createConnector('internal-server-error'); $resp = $conn->retrieve('id'); } @@ -100,11 +101,12 @@ class ConnectorTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\RequestErrorException - * @expectedExceptionCode 400 */ public function testBadRequestError() { + $this->expectException(\VuFindSearch\Backend\Exception\RequestErrorException::class); + $this->expectExceptionCode(400); + $conn = $this->createConnector('bad-request'); $resp = $conn->retrieve('id'); } @@ -114,11 +116,12 @@ class ConnectorTest extends TestCase * * @return void * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage AdapterInterface */ public function testSetAdapterThrowsInvalidObject() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('AdapterInterface'); + $conn = $this->createConnector('single-record'); $conn->setAdapter($this); } @@ -128,11 +131,12 @@ class ConnectorTest extends TestCase * * @return void * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Unable to serialize */ public function testSaveThrowsUnknownFormat() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unable to serialize'); + $conn = $this->createConnector(); $document = $this->createMock(\VuFindSearch\Backend\Solr\Document\UpdateDocument::class); $conn->write($document, 'unknown', 'update'); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php index d57e9e5ba01..e65a186b10a 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php @@ -28,11 +28,8 @@ */ namespace VuFindTest\Backend\Solr; -use InvalidArgumentException; - use PHPUnit\Framework\TestCase; -use RuntimeException; use VuFindSearch\Backend\Solr\HandlerMap; /** @@ -51,11 +48,12 @@ class HandlerMapTest extends TestCase * * @return void * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Duplicate fallback */ public function testSetHandlerMapThrowsOnDuplicateFallback() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Duplicate fallback'); + $map = [ 'h1' => ['fallback' => true], 'h2' => ['fallback' => true], @@ -68,11 +66,12 @@ class HandlerMapTest extends TestCase * * @return void * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Handler for function already defined */ public function testSetHandlerMapThrowsOnDuplicateFunctionHandler() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Handler for function already defined'); + $map = [ 'h1' => ['functions' => ['foo']], 'h2' => ['functions' => ['foo']], @@ -85,11 +84,12 @@ class HandlerMapTest extends TestCase * * @return void * - * @expectedException RuntimeException - * @expectedExceptionMessage Undefined function handler */ public function testGetHandlerThrowsOnUndefinedFunctionHandler() { + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Undefined function handler'); + $map = new HandlerMap([]); $map->getHandler('search'); } @@ -99,11 +99,12 @@ class HandlerMapTest extends TestCase * * @return void * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid parameter key: bad */ public function testGetParametersThrowsOnUndefinedType() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid parameter key: bad'); + $map = new HandlerMap(['h1' => ['functions' => ['foo']]]); $map->getParameters('h1', 'bad'); } @@ -113,11 +114,12 @@ class HandlerMapTest extends TestCase * * @return void * - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid parameter key: bad */ public function testSetParametersThrowsOnUndefinedType() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid parameter key: bad'); + $map = new HandlerMap(['h1' => ['functions' => ['foo']]]); $map->setParameters('h1', 'bad', []); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php index 87a84a7a8b6..44bbb1aa549 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php @@ -60,11 +60,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testInvalidInput() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $fact = new RecordCollectionFactory(); $coll = $fact->factory('garbage'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php index f4aaf0fa213..6f3d9922343 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php @@ -54,7 +54,7 @@ class BackendTest extends TestCase * * @return void */ - protected function setup() + protected function setUp(): void { if (!class_exists('SerialsSolutions_Summon_Exception', true)) { $this->markTestIncomplete('Unable to autoload class: SerialsSolutions\Summon\Exception'); @@ -121,10 +121,11 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException */ public function testRetrieveWrapsSummonException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $fact = $this->createMock(\VuFindSearch\Response\RecordCollectionFactoryInterface::class); $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) @@ -173,10 +174,11 @@ class BackendTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException */ public function testSearchWrapsSummonException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $fact = $this->createMock(\VuFindSearch\Response\RecordCollectionFactoryInterface::class); $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionFactoryTest.php index 6c151d23980..ecfb188f38f 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionFactoryTest.php @@ -47,11 +47,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Record factory must be callable. */ public function testConstructorRequiresFactoryFunction() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Record factory must be callable.'); + $factory = new RecordCollectionFactory(12345); } @@ -60,11 +61,12 @@ class RecordCollectionFactoryTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testFactoryRequiresArray() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $factory = new RecordCollectionFactory( function () { } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php index 6c0ead00634..a17eac3d914 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php @@ -73,10 +73,11 @@ class ConnectorTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\RequestErrorException */ public function testGetHoldingsHttpFailure() { + $this->expectException(\VuFindSearch\Backend\Exception\RequestErrorException::class); + $client = $this->createMock(\Zend\Http\Client::class); $connector = new Connector('key', $client); $client->expects($this->once())->method('setMethod') diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/Response/XML/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/Response/XML/RecordCollectionFactoryTest.php index e1757470132..d20c7e6ccc5 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/Response/XML/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/Response/XML/RecordCollectionFactoryTest.php @@ -46,11 +46,12 @@ class RecordCollectionFactoryTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Record factory must be callable. */ public function testBadCallback() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Record factory must be callable.'); + $x = new RecordCollectionFactory('bad'); } @@ -59,11 +60,12 @@ class RecordCollectionFactoryTest extends \PHPUnit\Framework\TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unexpected type of value: Expected array, got string */ public function testBadFactoryInput() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unexpected type of value: Expected array, got string'); + $x = new RecordCollectionFactory(); $x->factory('bad'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php index 5a01351f7dc..ea415abaf12 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php @@ -140,11 +140,12 @@ class QueryGroupTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\InvalidArgumentException - * @expectedExceptionMessage Unknown or invalid boolean operator: fizz */ public function testIllegalOperator() { + $this->expectException(\VuFindSearch\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown or invalid boolean operator: fizz'); + $q = $this->getSampleQueryGroup(); $q->setOperator('fizz'); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php index c3db870f687..4fd0429edc2 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php @@ -86,11 +86,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRetrieveException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $service = $this->getService(); $backend = $this->getBackend(); $params = new ParamBag(['x' => 'y']); @@ -111,11 +112,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testSearchException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $service = $this->getService(); $backend = $this->getBackend(); $exception = new BackendException('test'); @@ -136,11 +138,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testGetIdsProxyingSearchException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $service = $this->getService(); $backend = $this->getBackend(); $exception = new BackendException('test'); @@ -161,11 +164,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testGetIdsException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + // Use a special backend for this test... $this->backend = $this->createMock(\VuFindTest\TestClassForGetIdsInterface::class); @@ -246,11 +250,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRetrieveBatchInterfaceException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + // Use a special backend for this test... $this->backend = $this->createMock(\VuFindTest\TestClassForRetrieveBatchInterface::class); @@ -279,11 +284,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRetrieveBatchNoInterfaceException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $service = $this->getService(); $backend = $this->getBackend(); $params = new ParamBag(['x' => 'y']); @@ -339,11 +345,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRandomInterfaceWithException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + // Use a special backend for this test... $this->backend = $this->createMock(\VuFindTest\TestClassForRandomInterface::class); @@ -511,11 +518,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRandomNoInterfaceWithExceptionAtFirstSearch() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $service = $this->getService(); $backend = $this->getBackend(); $exception = new BackendException('test'); @@ -538,11 +546,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRandomNoInterfaceWithExceptionAtItemSearch() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $limit = 10; $total = 20; $service = $this->getService(); @@ -581,11 +590,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testRandomNoInterfaceExceptionWithLessResultsThanLimit() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + $limit = 10; $total = 5; $service = $this->getService(); @@ -654,11 +664,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage foo does not support similar() */ public function testSimilarOnNonSupportingBackend() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('foo does not support similar()'); + $service = $this->getService(); $params = new ParamBag(['x' => 'y']); $service->similar('foo', 'bar', $params); @@ -669,11 +680,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Backend\Exception\BackendException - * @expectedExceptionMessage test */ public function testSimilarException() { + $this->expectException(\VuFindSearch\Backend\Exception\BackendException::class); + $this->expectExceptionMessage('test'); + // Use a special backend for this test... $this->backend = $this->createMock(\VuFindTest\TestBackendClassForSimilar::class); @@ -700,11 +712,12 @@ class SearchServiceTest extends TestCase * * @return void * - * @expectedException VuFindSearch\Exception\RuntimeException - * @expectedExceptionMessage Unable to resolve backend: retrieve, junk */ public function testFailedResolve() { + $this->expectException(\VuFindSearch\Exception\RuntimeException::class); + $this->expectExceptionMessage('Unable to resolve backend: retrieve, junk'); + $mockResponse = $this->createMock(\Zend\EventManager\ResponseCollection::class); $mockResponse->expects($this->any())->method('stopped')->will($this->returnValue(false)); $em = $this->createMock(\Zend\EventManager\EventManagerInterface::class); diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php index 733fcdeaf8c..46830e90c1c 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php @@ -54,7 +54,7 @@ class LessCompilerTest extends Unit\TestCase */ protected $compiler; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $temp = sys_get_temp_dir(); $testDest = $temp . '/vufind_less_comp_test/'; @@ -93,7 +93,7 @@ class LessCompilerTest extends Unit\TestCase ); } - public function setUp() + public function setUp(): void { $temp = sys_get_temp_dir(); $perms = fileperms($temp); @@ -106,7 +106,7 @@ class LessCompilerTest extends Unit\TestCase $this->compiler->setTempPath($temp . '/vufind_less_comp_test/cache'); } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { $temp = sys_get_temp_dir(); $testDest = $temp . '/vufind_less_comp_test/'; diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeCompilerTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeCompilerTest.php index 1638647c8dc..67a48c8f07c 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeCompilerTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeCompilerTest.php @@ -67,14 +67,14 @@ class ThemeCompilerTest extends Unit\TestCase * * @return void */ - public function setUp() + public function setUp(): void { $this->fixturePath = realpath(__DIR__ . '/../../fixtures/themes'); $this->info = new ThemeInfo($this->fixturePath, 'parent'); $this->targetPath = $this->info->getBaseDir() . '/compiled'; // Give up if the target directory already exists: if (is_dir($this->targetPath)) { - return $this->markTestSkipped('compiled theme already exists.'); + $this->markTestSkipped('compiled theme already exists.'); } } @@ -224,7 +224,7 @@ class ThemeCompilerTest extends Unit\TestCase * * @return void */ - public function tearDown() + public function tearDown(): void { $this->getThemeCompiler()->removeTheme('compiled'); } diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php index cebb80d60ee..2cdec12c715 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php @@ -50,7 +50,7 @@ class ThemeInfoTest extends Unit\TestCase /** * Constructor */ - public function setUp() + public function setUp(): void { $this->fixturePath = realpath(__DIR__ . '/../../fixtures/themes'); } @@ -83,11 +83,12 @@ class ThemeInfoTest extends Unit\TestCase * * @return void * - * @expectedException Exception - * @expectedExceptionMessage Cannot load theme: invalid */ public function testInvalidTheme() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Cannot load theme: invalid'); + $this->getThemeInfo()->setTheme('invalid'); } diff --git a/tests/vufind.php_cs b/tests/vufind.php_cs index 8920407197e..db7e362db19 100644 --- a/tests/vufind.php_cs +++ b/tests/vufind.php_cs @@ -59,6 +59,11 @@ $rules = [ 'non_printable_character' => true, 'ordered_imports' => true, 'phpdoc_no_access' => true, + 'php_unit_dedicate_assert_internal_type' => true, + 'php_unit_expectation' => true, + 'php_unit_method_casing' => true, + 'php_unit_mock' => true, + 'php_unit_no_expectation_annotation' => true, 'single_blank_line_at_eof' => true, 'single_class_element_per_statement' => true, 'single_import_per_statement' => true, -- GitLab