Fix order of if-else block (check time ending before actor is born (=
full warning) before checking time starting before actor birth (limited warning))
This commit is contained in:
		@@ -52,19 +52,19 @@ final class MDPlausi {
 | 
				
			|||||||
            // Evaluating actor birth
 | 
					            // Evaluating actor birth
 | 
				
			||||||
            if ($event->actor_birth_normalized !== false) {
 | 
					            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
 | 
					                // The actor was involved with the object totally before they were born
 | 
				
			||||||
                // Ended being involved before birth
 | 
					                // 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->_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;
 | 
					                    $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
 | 
					            // Evaluate actor death
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,5 +51,30 @@ final class MDPlausiTest extends TestCase {
 | 
				
			|||||||
        self::assertTrue($plausi->getWarningStatus());
 | 
					        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));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user