Skip to content
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
11 changes: 11 additions & 0 deletions src/Model/ArticleVoR.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

final class ArticleVoR extends ArticleVersion implements HasBanner, HasContent, HasImpactStatement, HasReferences, HasThumbnail
{
private $figuresPdf;
private $impactStatement;
private $banner;
private $thumbnail;
Expand Down Expand Up @@ -40,6 +41,7 @@ public function __construct(
int $volume,
string $elocationId,
string $pdf = null,
string $figuresPdf = null,
Sequence $subjects,
array $researchOrganisms,
PromiseInterface $abstract,
Expand Down Expand Up @@ -70,6 +72,7 @@ public function __construct(
$volume, $elocationId, $pdf, $subjects, $researchOrganisms, $abstract, $issue, $copyright, $authors, $reviewers, $relatedArticles,
$funding, $generatedDataSets, $usedDataSets, $additionalFiles);

$this->figuresPdf = $figuresPdf;
$this->impactStatement = $impactStatement;
$this->banner = $banner;
$this->thumbnail = $thumbnail;
Expand All @@ -85,6 +88,14 @@ public function __construct(
$this->authorResponse = $authorResponse;
}

/**
* @return string|null
*/
public function getFiguresPdf()
{
return $this->figuresPdf;
}

/**
* @return string|null
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Serializer/ArticleVoRNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ protected function denormalizeArticle(
$data['volume'],
$data['elocationId'],
$data['pdf'] ?? null,
$data['figuresPdf'] ?? null,
$data['subjects'],
$data['researchOrganisms'] ?? [],
$data['abstract'],
Expand Down Expand Up @@ -255,6 +256,10 @@ protected function normalizeArticle(
) : array {
$data['status'] = 'vor';

if ($article->getFiguresPdf()) {
$data['figuresPdf'] = $article->getFiguresPdf();
}

if ($article->getImpactStatement()) {
$data['impactStatement'] = $article->getImpactStatement();
}
Expand Down
1 change: 1 addition & 0 deletions test/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ private function defaultTestData()
'volume' => 4,
'elocationId' => 'e09560',
'pdf' => null,
'figuresPdf' => null,
'subjects' => new EmptySequence(),
'researchOrganisms' => [],
'abstract' => promise_for(new ArticleSection(new ArraySequence([new Paragraph('Article 09560 abstract text')]))),
Expand Down
16 changes: 16 additions & 0 deletions test/Model/ArticleVoRTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public function setUp()
$this->builder = Builder::for(ArticleVoR::class);
}

/**
* @test
*/
public function it_may_have_a_figures_pdf()
{
$with = $this->builder
->withFiguresPdf('http://www.example.com/article14107.pdf')
->__invoke();
$withOut = $this->builder
->withFiguresPdf(null)
->__invoke();

$this->assertSame('http://www.example.com/article14107.pdf', $with->getFiguresPdf());
$this->assertNull($withOut->getFiguresPdf());
}

/**
* @test
*/
Expand Down
4 changes: 4 additions & 0 deletions test/Serializer/ArticleVoRNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function normalizeProvider() : array
Builder::for(ArticleVoR::class)
->withTitlePrefix('title prefix')
->withPdf('http://www.example.com/')
->withFiguresPdf('http://www.example.com/figures')
->withSubjects(new ArraySequence([
Builder::for(Subject::class)
->withId('subject1')
Expand Down Expand Up @@ -328,6 +329,7 @@ public function normalizeProvider() : array
],
],
'status' => 'vor',
'figuresPdf' => 'http://www.example.com/figures',
'impactStatement' => 'A new hominin species has been unearthed in the Dinaledi Chamber of the Rising Star cave system in the largest assemblage of a single species of hominins yet discovered in Africa.',
'image' => [
'thumbnail' => [
Expand Down Expand Up @@ -523,6 +525,7 @@ function ($test) {
Builder::for(ArticleVoR::class)
->withTitlePrefix('title prefix')
->withPdf('http://www.example.com/')
->withFiguresPdf('http://www.example.com/figures')
->withSubjects(new ArraySequence([
Builder::for(Subject::class)
->withId('subject1')
Expand Down Expand Up @@ -555,6 +558,7 @@ function ($test) {
],
'researchOrganisms' => ['research organism'],
'status' => 'vor',
'figuresPdf' => 'http://www.example.com/figures',
'impactStatement' => 'A new hominin species has been unearthed in the Dinaledi Chamber of the Rising Star cave system in the largest assemblage of a single species of hominins yet discovered in Africa.',
'image' => [
'thumbnail' => [
Expand Down