From 41b04e6358fa885b36fac66f9b98519a036de4b0 Mon Sep 17 00:00:00 2001 From: LinaKind Date: Thu, 5 Dec 2024 10:04:16 +0000 Subject: [PATCH] Define expected behaviour with elife assessment class with tests https://github.com/elifesciences/issues/issues/9034 --- src/Model/ElifeAssessment.php | 14 ++++++++---- test/Model/ElifeAssessmentTest.php | 34 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 test/Model/ElifeAssessmentTest.php diff --git a/src/Model/ElifeAssessment.php b/src/Model/ElifeAssessment.php index 6aef6857..c8a18a89 100644 --- a/src/Model/ElifeAssessment.php +++ b/src/Model/ElifeAssessment.php @@ -11,19 +11,25 @@ final class ElifeAssessment implements Model * @internal */ public function __construct( - array $significance, - array $strength + array $significance = null, + array $strength = null ) { $this->significance = $significance; $this->strength = $strength; } - public function getSignificance() : array + /** + * @return array|null + */ + public function getSignificance() { return $this->significance; } - public function getStrength() : array + /** + * @return array|null + */ + public function getStrength() { return $this->strength; } diff --git a/test/Model/ElifeAssessmentTest.php b/test/Model/ElifeAssessmentTest.php new file mode 100644 index 00000000..20205d3d --- /dev/null +++ b/test/Model/ElifeAssessmentTest.php @@ -0,0 +1,34 @@ +assertSame(['important'], $with->getSignificance()); + $this->assertNull($withOut->getSignificance()); + } + + /** + * @test + */ + public function it_may_have_strength_terms() + { + $with = new ElifeAssessment(['important'], ['solid']); + $withOut = new ElifeAssessment(['important']); + + $this->assertSame(['solid'], $with->getStrength()); + $this->assertNull($withOut->getStrength()); + } +}