Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests and remove array conversion #73

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Note that the JATS XML this plugin delivers it not intended for publication
i.e. using Lens Reader -- considerable additional improvement and quality
control would be required before the document is suitable for that purpose.

Tag | Definition | Support | Unit-tests |
| Tag | Definition | Support | Unit-tests |
|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|------------|
| [journal-id](https://jats.nlm.nih.gov/archiving/tag-library/1.3d1/element/journal-id.html) | Short code or abbreviation used as an identifier for a journal. | :ok: | :ok: |
| [journal-title-group](https://jats.nlm.nih.gov/archiving/tag-library/1.3d1/element/journal-title-group.html) | Container element for the titles of the journal in which the article was published. | :ok: | :ok: |
Expand Down
5 changes: 2 additions & 3 deletions classes/ArticleBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function create(Submission $submission): \DOMNode
// create element body
$bodyElement = $this->appendChild($this->createElement('body'));
$text = '';
$galleys = $submission->getCurrentPublication()->getData('galleys')->toArray();
$galleys = $submission->getCurrentPublication()->getData('galleys');

// Get HTML galleys for top of list, as they're quickest to parse
// PDFs have second-highest priority over other file types
$items = array_reduce($galleys, function (array $carry, Galley $galley) {
$items = $galleys->reduce(function (array $carry, Galley $galley) {
$fileType = $galley->getFileType();

switch ($fileType) {
Expand All @@ -50,7 +50,6 @@ public function create(Submission $submission): \DOMNode
return $carry;
}, ['html' => [], 'pdf' => [], 'other' => []]);
$galleys = array_merge($items['html'], $items['pdf'], $items['other']);

// Provide the full-text.
$fileService = app()->get('file');
foreach ($galleys as $galley) {
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/ArticleBackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private function createOAIRecordMockObject(): OAIRecord
$galleyDoiObject->setData('doi', 'galley-doi');

// Galleys
$galley = Repo::galley()->newDataObject();
/** @var Galley|MockObject */
$galley = $this->getMockBuilder(Galley::class)
->onlyMethods(['getFileType', 'getBestGalleyId'])
Expand All @@ -111,7 +110,7 @@ private function createOAIRecordMockObject(): OAIRecord
$galley->setData('submissionFileId', 98);
$galley->setData('doiObject', $galleyDoiObject);

$galleys = [$galley];
$galleys = collect([$galley]);

// Article
/** @var Submission|MockObject */
Expand Down Expand Up @@ -148,6 +147,9 @@ private function createOAIRecordMockObject(): OAIRecord
$journal->setPath('journal-path');
$journal->setData(Journal::SETTING_ENABLE_DOIS, true);
$journal->setData('abbreviation', 'publicknowledgeJ Pub Know', 'en');
$journal->setData('publisherInstitution', 'journal-publisher');
$journal->setData('onlineIssn', 'onlineIssn');
$journal->setData('printIssn', 'printIssn');
$journal->setId($journalId);

// Section
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/ArticleBodyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ private function createOAIRecordMockObject(): OAIRecord
$galleyDoiObject->setData('doi', 'galley-doi');

// Galleys
$galley = Repo::galley()->newDataObject();
/** @var Galley|MockObject */
$galley = $this->getMockBuilder(Galley::class)
->onlyMethods(['getFileType', 'getBestGalleyId'])
Expand All @@ -110,7 +109,7 @@ private function createOAIRecordMockObject(): OAIRecord
$galley->setData('submissionFileId', 12);
$galley->setData('doiObject', $galleyDoiObject);

$galleys = [$galley];
$galleys = collect([$galley]);
$publication->setData('galleys', $galleys);

// Article
Expand Down Expand Up @@ -148,6 +147,9 @@ private function createOAIRecordMockObject(): OAIRecord
$journal->setPath('journal-path');
$journal->setData(Journal::SETTING_ENABLE_DOIS, true);
$journal->setData('abbreviation', 'publicknowledgeJ Pub Know', 'en');
$journal->setData('publisherInstitution', 'journal-publisher');
$journal->setData('onlineIssn', 'onlineIssn');
$journal->setData('printIssn', 'printIssn');
$journal->setId($journalId);

// Section
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/ArticleFrontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ private function createOAIRecordMockObject(): OAIRecord
$galleyDoiObject->setData('doi', 'galley-doi');

// Galleys
$galley = Repo::galley()->newDataObject();
/** @var Galley|MockObject */
$galley = $this->getMockBuilder(Galley::class)
->onlyMethods(['getFileType', 'getBestGalleyId'])
Expand All @@ -133,7 +132,7 @@ private function createOAIRecordMockObject(): OAIRecord
$galley->setId(98);
$galley->setData('doiObject', $galleyDoiObject);

$galleys = [$galley];
$galleys = collect([$galley]);

// Journal
/** @var Journal|MockObject */
Expand All @@ -153,6 +152,9 @@ private function createOAIRecordMockObject(): OAIRecord
$journal->setPath('journal-path');
$journal->setData(Journal::SETTING_ENABLE_DOIS, true);
$journal->setData('abbreviation', 'publicknowledgeJ Pub Know', 'en');
$journal->setData('publisherInstitution', 'journal-publisher');
$journal->setData('onlineIssn', 'onlineIssn');
$journal->setData('printIssn', 'printIssn');
$journal->setId($journalId);

// Section
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/ArticleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ private function createOAIRecordMockObject(): OAIRecord
->getMock();
$galleyDoiObject->setData('doi', 'galley-doi');
// Galleys
$galley = Repo::galley()->newDataObject();
/** @var Galley|MockObject */
$galley = $this->getMockBuilder(Galley::class)
->onlyMethods(['getFileType', 'getBestGalleyId'])
Expand All @@ -122,7 +121,7 @@ private function createOAIRecordMockObject(): OAIRecord
$galley->setData('submissionFileId', 98);
$galley->setData('doiObject', $galleyDoiObject);

$galleys = [$galley];
$galleys = collect([$galley]);
$publication->setData('galleys', $galleys);

/** @var Doi|MockObject */
Expand Down Expand Up @@ -166,6 +165,9 @@ private function createOAIRecordMockObject(): OAIRecord
$journal->setPath('journal-path');
$journal->setData(Journal::SETTING_ENABLE_DOIS, true);
$journal->setData('abbreviation', 'publicknowledgeJ Pub Know', 'en');
$journal->setData('publisherInstitution', 'journal-publisher');
$journal->setData('onlineIssn', 'onlineIssn');
$journal->setData('printIssn', 'printIssn');
$journal->setId($journalId);

// Section
Expand Down