From fc34c9fcca84fe602a1e694e1c8ad7aeb5e048c3 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Mon, 12 Aug 2024 13:51:52 +0600 Subject: [PATCH] pkp/pkp-lib#9892 upgrade to laravel 11 and PHP 8.2+ --- .../migration/install/MetricsMigration.php | 29 ++++++------- classes/migration/install/OPSMigration.php | 16 +++---- .../migration/install/ServersMigration.php | 2 +- .../upgrade/v3_4_0/I6093_AddForeignKeys.php | 3 +- .../upgrade/v3_4_0/I6759_RenameVariables.php | 2 +- .../v3_4_0/I9231_FixMetricsIndexes.php | 28 ++++++------- .../upgrade/v3_4_0/ReviewFormsMigration.php | 4 +- dbscripts/xml/upgrade.xml | 1 + .../dc/tests/OAIMetadataFormat_DCTest.php | 39 +++++++++-------- .../search/PreprintSearchIndexTest.php | 42 ++++--------------- tests/classes/search/PreprintSearchTest.php | 13 +++--- .../importexport/PubObjectCacheTest.php | 15 +------ 12 files changed, 74 insertions(+), 120 deletions(-) diff --git a/classes/migration/install/MetricsMigration.php b/classes/migration/install/MetricsMigration.php index 62219e07e4..02af9911d1 100644 --- a/classes/migration/install/MetricsMigration.php +++ b/classes/migration/install/MetricsMigration.php @@ -195,16 +195,15 @@ public function up(): void $table->integer('metric_unique'); $table->index(['context_id', 'submission_id'], 'msgd_context_id_submission_id'); - switch (DB::getDriverName()) { - case 'mysql': + match (DB::getDriverName()) { + 'mysql', 'mariadb' => // See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html // where city is defined as varchar(80) - $table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date'); - break; - case 'pgsql': - $table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date'); - break; - } + $table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date'), + + 'pgsql' => + $table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date'), + }; }); Schema::create('metrics_submission_geo_monthly', function (Blueprint $table) { @@ -227,16 +226,14 @@ public function up(): void $table->integer('metric_unique'); $table->index(['context_id', 'submission_id'], 'msgm_context_id_submission_id'); - switch (DB::getDriverName()) { - case 'mysql': + match (DB::getDriverName()) { + 'mysql', 'mariadb' => // See "Create a database table" here: https://db-ip.com/db/format/ip-to-city-lite/csv.html // where city is defined as varchar(80) - $table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month'); - break; - case 'pgsql': - $table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month'); - break; - } + $table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month'), + 'pgsql' => + $table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month'), + }; }); // Usage stats total item temporary records diff --git a/classes/migration/install/OPSMigration.php b/classes/migration/install/OPSMigration.php index 10b9e62956..5db8ab093b 100644 --- a/classes/migration/install/OPSMigration.php +++ b/classes/migration/install/OPSMigration.php @@ -38,7 +38,7 @@ public function up(): void $table->foreign('review_form_id')->references('review_form_id')->on('review_forms')->onDelete('set null'); $table->index(['review_form_id'], 'sections_review_form_id'); - $table->float('seq', 8, 2)->default(0); + $table->float('seq')->default(0); $table->tinyInteger('editor_restricted')->default(0); $table->tinyInteger('meta_indexed')->default(0); $table->tinyInteger('meta_reviewed')->default(1); @@ -122,7 +122,7 @@ public function up(): void $table->foreign('submission_file_id')->references('submission_file_id')->on('submission_files')->onDelete('SET NULL'); $table->index(['submission_file_id'], 'publication_galleys_submission_file_id'); - $table->float('seq', 8, 2)->default(0); + $table->float('seq')->default(0); $table->string('remote_url', 2047)->nullable(); $table->tinyInteger('is_approved')->default(0); @@ -152,12 +152,12 @@ public function up(): void // Add partial index (DBMS-specific) - switch (DB::getDriverName()) { - case 'mysql': DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name(50), setting_value(150))'); - break; - case 'pgsql': DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name, setting_value)'); - break; - } + match (DB::getDriverName()) { + 'mysql', 'mariadb' => + DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name(50), setting_value(150))'), + 'pgsql' => + DB::unprepared('CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name, setting_value)'), + }; } /** diff --git a/classes/migration/install/ServersMigration.php b/classes/migration/install/ServersMigration.php index c60640dae4..f9c302a76d 100644 --- a/classes/migration/install/ServersMigration.php +++ b/classes/migration/install/ServersMigration.php @@ -29,7 +29,7 @@ public function up(): void $table->comment('A list of preprint servers managed by the installation.'); $table->bigInteger('server_id')->autoIncrement(); $table->string('path', 32); - $table->float('seq', 8, 2)->default(0)->comment('Used to order lists of servers'); + $table->float('seq')->default(0)->comment('Used to order lists of servers'); $table->string('primary_locale', 28); $table->tinyInteger('enabled')->default(1)->comment('Controls whether or not the server is considered "live" and will appear on the website. (Note that disabled servers may still be accessible, but only if the user knows the URL.)'); $table->unique(['path'], 'servers_path'); diff --git a/classes/migration/upgrade/v3_4_0/I6093_AddForeignKeys.php b/classes/migration/upgrade/v3_4_0/I6093_AddForeignKeys.php index af85754bbc..634ea4664e 100644 --- a/classes/migration/upgrade/v3_4_0/I6093_AddForeignKeys.php +++ b/classes/migration/upgrade/v3_4_0/I6093_AddForeignKeys.php @@ -15,7 +15,6 @@ namespace APP\migration\upgrade\v3_4_0; use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; class I6093_AddForeignKeys extends \PKP\migration\upgrade\v3_4_0\I6093_AddForeignKeys @@ -49,7 +48,7 @@ public function up(): void }); // Attempt to drop the previous foreign key, which doesn't have the cascade rule - if (DB::getDoctrineSchemaManager()->introspectTable('publication_galleys')->hasForeignKey('publication_galleys_submission_file_id_foreign')) { + if ($this->hasForeignKey('publication_galleys', 'publication_galleys_submission_file_id_foreign')) { Schema::table('publication_galleys', fn (Blueprint $table) => $table->dropForeign('publication_galleys_submission_file_id_foreign')); } diff --git a/classes/migration/upgrade/v3_4_0/I6759_RenameVariables.php b/classes/migration/upgrade/v3_4_0/I6759_RenameVariables.php index 77882e65ef..58c120a54a 100644 --- a/classes/migration/upgrade/v3_4_0/I6759_RenameVariables.php +++ b/classes/migration/upgrade/v3_4_0/I6759_RenameVariables.php @@ -64,7 +64,7 @@ private function _updateTablesWithReference() Schema::table('servers', function (Blueprint $table) { $table->renameColumn('journal_id', 'server_id'); - $table->float('seq', 8, 2)->comment('Used to order lists of servers')->change(); + $table->float('seq')->comment('Used to order lists of servers')->change(); $table->smallInteger('enabled')->default(1)->comment('Controls whether or not the server is considered "live" and will appear on the website. (Note that disabled servers may still be accessible, but only if the user knows the URL.)')->change(); $table->unique(['path'], 'servers_path'); }); diff --git a/classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php b/classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php index 5a7c0dbcd3..924b56dd8c 100644 --- a/classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php +++ b/classes/migration/upgrade/v3_4_0/I9231_FixMetricsIndexes.php @@ -51,25 +51,21 @@ public function up(): void // and create new ones using city column prefix for MySQL Schema::table('metrics_submission_geo_daily', function (Blueprint $table) { $table->dropUnique('msgd_uc_load_context_submission_c_r_c_date'); - switch (DB::getDriverName()) { - case 'mysql': - $table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date'); - break; - case 'pgsql': - $table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date'); - break; - } + match (DB::getDriverName()) { + 'mysql', 'mariadb' => + $table->unique([DB::raw('load_id, context_id, submission_id, country, region, city(80), date')], 'msgd_uc_load_context_submission_c_r_c_date'), + 'pgsql' => + $table->unique(['load_id', 'context_id', 'submission_id', 'country', 'region', 'city', 'date'], 'msgd_uc_load_context_submission_c_r_c_date'), + }; }); Schema::table('metrics_submission_geo_monthly', function (Blueprint $table) { $table->dropUnique('msgm_uc_context_submission_c_r_c_month'); - switch (DB::getDriverName()) { - case 'mysql': - $table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month'); - break; - case 'pgsql': - $table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month'); - break; - } + match (DB::getDriverName()) { + 'mysql', 'mariadb' => + $table->unique([DB::raw('context_id, submission_id, country, region, city(80), month')], 'msgm_uc_context_submission_c_r_c_month'), + 'pgsql' => + $table->unique(['context_id', 'submission_id', 'country', 'region', 'city', 'month'], 'msgm_uc_context_submission_c_r_c_month'), + }; }); } diff --git a/classes/migration/upgrade/v3_4_0/ReviewFormsMigration.php b/classes/migration/upgrade/v3_4_0/ReviewFormsMigration.php index bb3a882c40..3e60e1dc28 100644 --- a/classes/migration/upgrade/v3_4_0/ReviewFormsMigration.php +++ b/classes/migration/upgrade/v3_4_0/ReviewFormsMigration.php @@ -32,7 +32,7 @@ public function up(): void $table->bigInteger('review_form_id')->autoIncrement(); $table->bigInteger('assoc_type'); $table->bigInteger('assoc_id'); - $table->float('seq', 8, 2)->nullable(); + $table->float('seq')->nullable(); $table->smallInteger('is_active')->nullable(); }); } @@ -54,7 +54,7 @@ public function up(): void Schema::create('review_form_elements', function (Blueprint $table) { $table->bigInteger('review_form_element_id')->autoIncrement(); $table->bigInteger('review_form_id'); - $table->float('seq', 8, 2)->nullable(); + $table->float('seq')->nullable(); $table->bigInteger('element_type')->nullable(); $table->smallInteger('required')->nullable(); $table->smallInteger('included')->nullable(); diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml index 8ad74f1538..fee2411b53 100644 --- a/dbscripts/xml/upgrade.xml +++ b/dbscripts/xml/upgrade.xml @@ -65,6 +65,7 @@ + diff --git a/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php b/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php index 4da82e7b8e..3db04df7f5 100755 --- a/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php +++ b/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php @@ -35,6 +35,7 @@ use APP\server\Server; use APP\submission\Submission; use Illuminate\Support\LazyCollection; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use PKP\core\Dispatcher; use PKP\core\Registry; @@ -47,6 +48,8 @@ use PKP\submission\SubmissionSubjectDAO; use PKP\tests\PKPTestCase; +#[CoversClass(OAIMetadataFormat_DC::class)] +#[CoversClass(\APP\plugins\metadata\dc11\filter\Dc11SchemaPreprintAdapter::class)] class OAIMetadataFormat_DCTest extends PKPTestCase { /** @@ -65,10 +68,6 @@ protected function getMockedRegistryKeys(): array return [...parent::getMockedRegistryKeys(), 'request']; } - /** - * @covers OAIMetadataFormat_DC - * @covers \APP\plugins\metadata\dc11\filter\Dc11SchemaPreprintAdapter - */ public function testToXml() { // @@ -114,14 +113,14 @@ public function testToXml() ->getMock(); $preprint->expects($this->any()) ->method('getBestId') - ->will($this->returnValue(9)); + ->willReturn(9); $preprint->setData('locale', 'en'); $preprint->setId(9); $preprint->setData('contextId', $serverId); $author->setSubmissionId($preprint->getId()); $preprint->expects($this->any()) ->method('getCurrentPublication') - ->will($this->returnValue($publication)); + ->willReturn($publication); /** @var Doi|MockObject */ $galleyDoiObject = $this->getMockBuilder(Doi::class) @@ -138,10 +137,10 @@ public function testToXml() ->getMock(); $galley->expects(self::any()) ->method('getFileType') - ->will($this->returnValue('galley-filetype')); + ->willReturn('galley-filetype'); $galley->expects(self::any()) ->method('getBestGalleyId') - ->will($this->returnValue(98)); + ->willReturn(98); $galley->setId(98); $galley->setData('doiObject', $galleyDoiObject); $galley->setData('locale', 'en'); @@ -156,7 +155,7 @@ public function testToXml() $server->expects($this->any()) ->method('getSetting') ->with('publishingMode') - ->will($this->returnValue(Server::PUBLISHING_MODE_OPEN)); + ->willReturn(Server::PUBLISHING_MODE_OPEN); $server->setName('server-title', 'en'); $server->setData('publisherInstitution', 'server-publisher'); $server->setPrimaryLocale('en'); @@ -183,16 +182,16 @@ public function testToXml() $router->setApplication($application); $router->expects($this->any()) ->method('url') - ->will($this->returnCallback(fn ($request, $newContext = null, $handler = null, $op = null, $path = null) => $handler . '-' . $op . '-' . implode('-', $path))); + ->willReturnCallback(fn ($request, $newContext = null, $handler = null, $op = null, $path = null) => $handler . '-' . $op . '-' . implode('-', $path)); // Dispatcher /** @var Dispatcher|MockObject */ $dispatcher = $this->getMockBuilder(Dispatcher::class) - ->onlyMethods(['url']) - ->getMock(); + ->onlyMethods(['url']) + ->getMock(); $dispatcher->expects($this->any()) ->method('url') - ->will($this->returnCallback(fn ($request, $shortcut, $newContext = null, $handler = null, $op = null, $path = null) => $handler . '-' . $op . '-' . implode('-', $path))); + ->willReturnCallback(fn ($request, $shortcut, $newContext = null, $handler = null, $op = null, $path = null) => $handler . '-' . $op . '-' . implode('-', $path)); // Request $requestMock = $this->getMockBuilder(Request::class) @@ -200,10 +199,10 @@ public function testToXml() ->getMock(); $requestMock->expects($this->any()) ->method('getRouter') - ->will($this->returnValue($router)); + ->willReturn($router); $requestMock->expects($this->any()) ->method('getDispatcher') - ->will($this->returnValue($dispatcher)); + ->willReturn($dispatcher); Registry::set('request', $requestMock); @@ -217,10 +216,10 @@ public function testToXml() ->getMock(); $oaiDao->expects($this->any()) ->method('getServer') - ->will($this->returnValue($server)); + ->willReturn($server); $oaiDao->expects($this->any()) ->method('getSection') - ->will($this->returnValue($section)); + ->willReturn($section); DAORegistry::registerDAO('OAIDAO', $oaiDao); /** @var GalleyCollector|MockObject */ @@ -230,7 +229,7 @@ public function testToXml() ->getMock(); $mockGalleyCollector->expects($this->any()) ->method('getMany') - ->will($this->returnValue(LazyCollection::wrap($galleys))); + ->willReturn(LazyCollection::wrap($galleys)); app()->instance(GalleyCollector::class, $mockGalleyCollector); // Mocked DAO to return the subjects @@ -239,7 +238,7 @@ public function testToXml() ->getMock(); $submissionSubjectDao->expects($this->any()) ->method('getSubjects') - ->will($this->returnValue(['en' => ['preprint-subject', 'preprint-subject-class']])); + ->willReturn(['en' => ['preprint-subject', 'preprint-subject-class']]); DAORegistry::registerDAO('SubmissionSubjectDAO', $submissionSubjectDao); // Mocked DAO to return the keywords @@ -248,7 +247,7 @@ public function testToXml() ->getMock(); $submissionKeywordDao->expects($this->any()) ->method('getKeywords') - ->will($this->returnValue(['en' => ['preprint-keyword']])); + ->willReturn(['en' => ['preprint-keyword']]); DAORegistry::registerDAO('SubmissionKeywordDAO', $submissionKeywordDao); // diff --git a/tests/classes/search/PreprintSearchIndexTest.php b/tests/classes/search/PreprintSearchIndexTest.php index 01d936c00c..d60a4264c1 100644 --- a/tests/classes/search/PreprintSearchIndexTest.php +++ b/tests/classes/search/PreprintSearchIndexTest.php @@ -26,6 +26,7 @@ use APP\submission\Submission; use Mockery; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use PKP\db\DAORegistry; use PKP\db\DAOResultFactory; @@ -34,6 +35,7 @@ use PKP\submissionFile\SubmissionFile; use PKP\tests\PKPTestCase; +#[CoversClass(PreprintSearchIndex::class)] class PreprintSearchIndexTest extends PKPTestCase { // @@ -77,9 +79,7 @@ protected function tearDown(): void // // Unit tests // - /** - * @covers PreprintSearchIndex - */ + public function testUpdateFileIndexViaPluginHook() { // Diverting to the search plugin hook. @@ -100,9 +100,6 @@ public function testUpdateFileIndexViaPluginHook() Hook::clear('PreprintSearchIndex::submissionFileChanged'); } - /** - * @covers PreprintSearchIndex - */ public function testDeleteTextIndex() { // Prepare the mock environment for this test. @@ -116,9 +113,6 @@ public function testDeleteTextIndex() $preprintSearchIndex->submissionFileDeleted(0); } - /** - * @covers PreprintSearchIndex - */ public function testDeleteTextIndexViaPluginHook() { // Diverting to the search plugin hook. @@ -140,9 +134,6 @@ public function testDeleteTextIndexViaPluginHook() Hook::clear('PreprintSearchIndex::submissionFileDeleted'); } - /** - * @covers PreprintSearchIndex - */ public function testRebuildIndex() { // Prepare the mock environment for this test. @@ -160,9 +151,6 @@ public function testRebuildIndex() $preprintSearchIndex->rebuildIndex(true); } - /** - * @covers PreprintSearchIndex - */ public function testRebuildIndexViaPluginHook() { // Diverting to the search plugin hook. @@ -180,9 +168,6 @@ public function testRebuildIndexViaPluginHook() Hook::clear('PreprintSearchIndex::rebuildIndex'); } - /** - * @covers PreprintSearchIndex - */ public function testIndexPreprintMetadata() { // Make sure that no hook is being called. @@ -203,16 +188,13 @@ public function testIndexPreprintMetadata() ->getMock(); $preprint->expects($this->any()) ->method('getCurrentPublication') - ->will($this->returnValue($publication)); + ->willReturn($publication); // Test indexing an preprint with a mock environment. $preprintSearchIndex = $this->getMockPreprintSearchIndex($this->atLeastOnce()); $preprintSearchIndex->submissionMetadataChanged($preprint); } - /** - * @covers PreprintSearchIndex - */ public function testIndexPreprintMetadataViaPluginHook() { // Diverting to the search plugin hook. @@ -231,9 +213,6 @@ public function testIndexPreprintMetadataViaPluginHook() Hook::clear('PreprintSearchIndex::preprintMetadataChanged'); } - /** - * @covers PreprintSearchIndex - */ public function testIndexSubmissionFiles() { // Make sure that no hook is being called. @@ -247,9 +226,6 @@ public function testIndexSubmissionFiles() $this->assertTrue(true); } - /** - * @covers PreprintSearchIndex - */ public function testIndexSubmissionFilesViaPluginHook() { // Diverting to the search plugin hook. @@ -389,12 +365,12 @@ private function registerMockPreprintSearchDAO($clearIndexExpected, $deletePrepr // Test the clearIndex() method. $preprintSearchDao->expects($clearIndexExpected) ->method('clearIndex') - ->will($this->returnValue(null)); + ->willReturn(null); // Test the deleteSubmissionKeywords() method. $preprintSearchDao->expects($deletePreprintExpected) ->method('deleteSubmissionKeywords') - ->will($this->returnValue(null)); + ->willReturn(null); // Register the mock DAO. DAORegistry::registerDAO('PreprintSearchDAO', $preprintSearchDao); @@ -418,12 +394,12 @@ private function registerMockServerDAO() ->getMock(); $serversIterator ->method('toIterator') - ->will($this->returnValue(new \ArrayIterator())); + ->willReturn(new \ArrayIterator()); // Mock the getAll() method. $serverDao->expects($this->any()) ->method('getAll') - ->will($this->returnValue($serversIterator)); + ->willReturn($serversIterator); // Register the mock DAO. DAORegistry::registerDAO('ServerDAO', $serverDao); @@ -461,7 +437,7 @@ private function getMockPreprintSearchIndex($expectedCall) // Check for _updateTextIndex() calls. $preprintSearchIndex->expects($expectedCall) ->method('_updateTextIndex') - ->will($this->returnValue(null)); + ->willReturn(null); return $preprintSearchIndex; } } diff --git a/tests/classes/search/PreprintSearchTest.php b/tests/classes/search/PreprintSearchTest.php index 075526858d..6862259bad 100644 --- a/tests/classes/search/PreprintSearchTest.php +++ b/tests/classes/search/PreprintSearchTest.php @@ -24,10 +24,12 @@ use APP\search\PreprintSearchDAO; use APP\server\Server; use APP\server\ServerDAO; +use PHPUnit\Framework\Attributes\CoversClass; use PKP\db\DAORegistry; use PKP\plugins\Hook; use PKP\tests\PKPTestCase; +#[CoversClass(PreprintSearch::class)] class PreprintSearchTest extends PKPTestCase { private const SUBMISSION_SEARCH_TEST_DEFAULT_PREPRINT = 1; @@ -77,9 +79,7 @@ protected function tearDown(): void // // Unit tests // - /** - * @covers PreprintSearch - */ + public function testRetrieveResults() { // Make sure that no hook is being called. @@ -101,9 +101,6 @@ public function testRetrieveResults() self::assertEquals('', $error); } - /** - * @covers PreprintSearch - */ public function testRetrieveResultsViaPluginHook() { // Diverting a search to the search plugin hook. @@ -215,7 +212,7 @@ private function registerMockPreprintSearchDAO() // Mock the getPhraseResults() method. $preprintSearchDao->expects($this->any()) ->method('getPhraseResults') - ->will($this->returnValue($searchResult)); + ->willReturn($searchResult); // Register the mock DAO. DAORegistry::registerDAO('PreprintSearchDAO', $preprintSearchDao); @@ -239,7 +236,7 @@ private function registerMockServerDAO() // Mock the getById() method. $serverDao->expects($this->any()) ->method('getById') - ->will($this->returnValue($server)); + ->willReturn($server); // Register the mock DAO. DAORegistry::registerDAO('ServerDAO', $serverDao); diff --git a/tests/plugins/importexport/PubObjectCacheTest.php b/tests/plugins/importexport/PubObjectCacheTest.php index 076dde19c5..f1e423c0cc 100755 --- a/tests/plugins/importexport/PubObjectCacheTest.php +++ b/tests/plugins/importexport/PubObjectCacheTest.php @@ -24,13 +24,12 @@ use APP\facades\Repo; use APP\plugins\PubObjectCache; use APP\submission\Submission; +use PHPUnit\Framework\Attributes\CoversClass; use PKP\tests\PKPTestCase; +#[CoversClass(PubObjectCache::class)] class PubObjectCacheTest extends PKPTestCase { - /** - * @covers PubObjectCache - */ public function testAddSubmission() { $cache = new PubObjectCache(); @@ -46,9 +45,6 @@ public function testAddSubmission() self::assertEquals($submission, $retrievedIssue); } - /** - * @covers PubObjectCache - */ public function testAddPreprint() { $cache = new PubObjectCache(); @@ -69,10 +65,6 @@ public function testAddPreprint() self::assertEquals($preprint, $retrievedPreprint); } - - /** - * @covers PubObjectCache - */ public function testAddGalley() { $nullVar = null; @@ -109,9 +101,6 @@ public function testAddGalley() self::assertFalse($cache->isCached('galleysByIssue', $preprint->getCurrentPublication()->getData('issueId'))); } - /** - * @covers PubObjectCache - */ public function testAddSeveralGalleys() { $nullVar = null;