Skip to content

Commit

Permalink
Make the ArticleSection mandatory for the ElifeAssessment constructor…
Browse files Browse the repository at this point in the history
… for simplification

elifesciences/issues#9034
  • Loading branch information
LinaKind committed Jan 10, 2025
1 parent bb735c5 commit 5dec13e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/Model/ElifeAssessment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ElifeAssessment implements Model
*/
public function __construct(
string $title,
ArticleSection $articleSection = null,
ArticleSection $articleSection,
array $significance = null,
array $strength = null
) {
Expand All @@ -29,10 +29,7 @@ public function getTitle(): string
return $this->title;
}

/**
* @return ArticleSection|null
*/
public function getArticleSection()
public function getArticleSection(): ArticleSection
{
return $this->articleSection;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private function defaultTestData()
ElifeAssessment::class => function () {
return [
'title' => 'eLife Assessment',
'articleSection' => null,
'articleSection' => new ArticleSection(new ArraySequence([new Paragraph('Article 09560 elife assessment text')]), '10.7554/eLife.09560elifeAssessment', 'elife-assessment-id'),
'significance' => ['Landmark', 'Important'],
'strength' => ['Solid', 'Adequate'],
];
Expand Down
2 changes: 1 addition & 1 deletion test/Model/ArticleVoRTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function it_may_be_vor_prc()
public function it_may_have_an_elife_assessment()
{
$with = $this->builder
->withElifeAssessment($elifeAssessment = new ElifeAssessment('elife assessment', null, ['solid'], null))
->withElifeAssessment($elifeAssessment = Builder::dummy(ElifeAssessment::class))
->__invoke();
$withOut = $this->builder
->withElifeAssessment(null)
Expand Down
10 changes: 5 additions & 5 deletions test/Model/ElifeAssessmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function set_up()
*/
public function it_has_a_title()
{
$assessment = new ElifeAssessment($this->title, null, null, null);
$assessment = new ElifeAssessment($this->title, $this->articleSection, null, null);

$this->assertSame($this->title, $assessment->getTitle());
}
Expand All @@ -46,8 +46,8 @@ public function it_has_an_article_section()
*/
public function it_may_have_significance_terms()
{
$with = new ElifeAssessment($this->title, null, ['important'], ['solid']);
$withOut = new ElifeAssessment($this->title, null, null, ['solid']);
$with = new ElifeAssessment($this->title, $this->articleSection, ['important'], ['solid']);
$withOut = new ElifeAssessment($this->title, $this->articleSection, null, ['solid']);

$this->assertSame(['important'], $with->getSignificance());
$this->assertNull($withOut->getSignificance());
Expand All @@ -58,8 +58,8 @@ public function it_may_have_significance_terms()
*/
public function it_may_have_strength_terms()
{
$with = new ElifeAssessment($this->title, null, ['important'], ['solid']);
$withOut = new ElifeAssessment($this->title, null, ['important'], null);
$with = new ElifeAssessment($this->title, $this->articleSection, ['important'], ['solid']);
$withOut = new ElifeAssessment($this->title, $this->articleSection, ['important'], null);

$this->assertSame(['solid'], $with->getStrength());
$this->assertNull($withOut->getStrength());
Expand Down

0 comments on commit 5dec13e

Please sign in to comment.