From 0883aed7e50444e3c6a4983d1025c68ff4b09ec6 Mon Sep 17 00:00:00 2001 From: Thiago Date: Mon, 21 Oct 2024 12:23:14 -0400 Subject: [PATCH 1/3] Fixes DOI retrieving --- classes/services/ThothWorkService.inc.php | 4 +-- .../classes/services/ThothWorkServiceTest.php | 28 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/classes/services/ThothWorkService.inc.php b/classes/services/ThothWorkService.inc.php index 084b174..98652b4 100644 --- a/classes/services/ThothWorkService.inc.php +++ b/classes/services/ThothWorkService.inc.php @@ -46,7 +46,7 @@ public function getDataBySubmission($submission, $publication = null) $data['subtitle'] = $publication->getLocalizedData('subtitle'); $data['longAbstract'] = $publication->getLocalizedData('abstract'); $data['edition'] = $publication->getData('version'); - $data['doi'] = $publication->getDoi(); + $data['doi'] = $publication->getData('doiObject')?->getResolvingUrl(); $data['publicationDate'] = $publication->getData('datePublished'); $data['license'] = $publication->getData('licenseUrl'); $data['copyrightHolder'] = $publication->getLocalizedData('copyrightHolder'); @@ -80,7 +80,7 @@ public function newByChapter($chapter) $params['pageCount'] = $chapter->getPages() ? (int) $chapter->getPages() : null; $params['publicationDate'] = $chapter->getDatePublished() ?? Repo::publication()->get($chapter->getData('publicationId'))->getData('datePublished'); - $params['doi'] = $chapter->getDoi(); + $params['doi'] = $chapter->getData('doiObject')?->getResolvingUrl(); return $this->new($params); } diff --git a/tests/classes/services/ThothWorkServiceTest.php b/tests/classes/services/ThothWorkServiceTest.php index a87ff06..ecc5048 100644 --- a/tests/classes/services/ThothWorkServiceTest.php +++ b/tests/classes/services/ThothWorkServiceTest.php @@ -227,9 +227,16 @@ public function testCreateNewWorkBySubmission() ->shouldReceive('getData') ->with('licenseUrl') ->andReturn('https://creativecommons.org/licenses/by-nc/4.0/') - ->shouldReceive('getDoi') - ->withAnyArgs() - ->andReturn('https://doi.org/10.1234/0000af0000') + ->shouldReceive('getData') + ->with('doiObject') + ->andReturn( + Mockery::mock(\PKP\doi\Doi::class) + ->makePartial() + ->shouldReceive('getResolvingUrl') + ->withAnyArgs() + ->andReturn('https://doi.org/10.1234/0000af0000') + ->getMock() + ) ->getMock() ) ->getMock(); @@ -264,10 +271,17 @@ public function testCreateNewWorkByChapter() ->andReturn('2024-03-21') ->shouldReceive('getPages') ->withAnyArgs() - ->andReturn(27) - ->shouldReceive('getDoi') - ->withAnyArgs() - ->andReturn('https://doi.org/10.1234/jpk.14.c54') + ->andReturn('27') + ->shouldReceive('getData') + ->with('doiObject') + ->andReturn( + Mockery::mock(\PKP\doi\Doi::class) + ->makePartial() + ->shouldReceive('getResolvingUrl') + ->withAnyArgs() + ->andReturn('https://doi.org/10.1234/jpk.14.c54') + ->getMock() + ) ->getMock(); $thothWork = $this->workService->newByChapter($chapterMock); From 43fcadf385e627698f65f2a3621d707b2102b577 Mon Sep 17 00:00:00 2001 From: Thiago Date: Mon, 21 Oct 2024 12:23:38 -0400 Subject: [PATCH 2/3] Update version.xml --- version.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.xml b/version.xml index 392ed27..e28a2f2 100644 --- a/version.xml +++ b/version.xml @@ -3,7 +3,7 @@ thoth plugins.generic - 0.2.1.1 + 0.2.1.2 2024-10-21 1 ThothPlugin From f6349fb5f40dc8c8210d199148c6bf7b47f5d143 Mon Sep 17 00:00:00 2001 From: Thiago Date: Mon, 21 Oct 2024 12:32:37 -0400 Subject: [PATCH 3/3] Fixes code formatting --- classes/services/ThothWorkService.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/services/ThothWorkService.inc.php b/classes/services/ThothWorkService.inc.php index 98652b4..2460be2 100644 --- a/classes/services/ThothWorkService.inc.php +++ b/classes/services/ThothWorkService.inc.php @@ -46,7 +46,9 @@ public function getDataBySubmission($submission, $publication = null) $data['subtitle'] = $publication->getLocalizedData('subtitle'); $data['longAbstract'] = $publication->getLocalizedData('abstract'); $data['edition'] = $publication->getData('version'); - $data['doi'] = $publication->getData('doiObject')?->getResolvingUrl(); + $data['doi'] = $publication->getData('doiObject') + ? $publication->getData('doiObject')->getResolvingUrl() + : null; $data['publicationDate'] = $publication->getData('datePublished'); $data['license'] = $publication->getData('licenseUrl'); $data['copyrightHolder'] = $publication->getLocalizedData('copyrightHolder'); @@ -80,7 +82,9 @@ public function newByChapter($chapter) $params['pageCount'] = $chapter->getPages() ? (int) $chapter->getPages() : null; $params['publicationDate'] = $chapter->getDatePublished() ?? Repo::publication()->get($chapter->getData('publicationId'))->getData('datePublished'); - $params['doi'] = $chapter->getData('doiObject')?->getResolvingUrl(); + $params['doi'] = $chapter->getData('doiObject') + ? $chapter->getData('doiObject')->getResolvingUrl() + : null; return $this->new($params); }