From aef095af3c7b2db1bf475664fae8b4efeec1ed74 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Fri, 6 Oct 2023 23:19:42 +0200 Subject: [PATCH] Fix order of if-else block (check time ending before actor is born (= full warning) before checking time starting before actor birth (limited warning)) --- src/Checks/Plausi/MDPlausi.php | 12 ++++++------ tests/MDPlausiTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/Checks/Plausi/MDPlausi.php b/src/Checks/Plausi/MDPlausi.php index 1d919cc..3853bed 100644 --- a/src/Checks/Plausi/MDPlausi.php +++ b/src/Checks/Plausi/MDPlausi.php @@ -52,19 +52,19 @@ final class MDPlausi { // Evaluating actor birth if ($event->actor_birth_normalized !== false) { - // Work on the object started before the actor was born - if ($event->time_start_normalized !== false && $event->time_start_normalized < $event->actor_birth_normalized) { - $this->_messageList[] = $this->_tlLoader->tl("eventtype_name", "eventname", (string)$event->event_type) . ' (' . $event->time_name . ') ' . $this->_tlLoader->tl("quality", "quality", "before_birth_possibly") . ' ' . $event->actor_name; - } - // The actor was involved with the object totally before they were born // Ended being involved before birth - else if ($event->time_end_normalized !== false && $event->time_end_normalized < $event->actor_birth_normalized) { + if ($event->time_end_normalized !== false && $event->time_end_normalized < $event->actor_birth_normalized) { $this->_messageList[] = $this->_tlLoader->tl("eventtype_name", "eventname", (string)$event->event_type) . ' (' . $event->time_name . ') ' . $this->_tlLoader->tl("quality", "quality", "before_birth") . ' ' . $event->actor_name; $this->_hasCertainWarnings = true; } + // Work on the object started before the actor was born + else if ($event->time_start_normalized !== false && $event->time_start_normalized < $event->actor_birth_normalized) { + $this->_messageList[] = $this->_tlLoader->tl("eventtype_name", "eventname", (string)$event->event_type) . ' (' . $event->time_name . ') ' . $this->_tlLoader->tl("quality", "quality", "before_birth_possibly") . ' ' . $event->actor_name; + } + } // Evaluate actor death diff --git a/tests/MDPlausiTest.php b/tests/MDPlausiTest.php index 0fa3f6d..0bf058f 100644 --- a/tests/MDPlausiTest.php +++ b/tests/MDPlausiTest.php @@ -51,5 +51,30 @@ final class MDPlausiTest extends TestCase { self::assertTrue($plausi->getWarningStatus()); + } + + /** + * Ensures that a warning is returned, Checks the integration / evaluation function. + * + * @return void + */ + public function testActorProducingObjectBeforeOwnBirthResultsInWarning():void { + + $tlLoader = new MDTlLoader("plausi_test", "en"); + + $plausiEvent = new MDPlausiEvent(1, + "1812", + "1812", + "1812", + "Helmut Meyer", + "1859", + "1900"); + + $plausi = new MDPlausi($tlLoader, [$plausiEvent]); + $plausi->evaluate(); + + self::assertTrue($plausi->getWarningStatus(), "Production before birth of the actor should result in a full warning." . PHP_EOL . PHP_EOL . "Current plausi status is:" . PHP_EOL . var_export($plausi, true)); + + } }