2022-04-02 19:34:16 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
2022-05-17 23:27:40 +02:00
|
|
|
* This script contains tests for the uncertainty helper.
|
2022-04-02 19:34:16 +02:00
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
2022-05-17 23:27:40 +02:00
|
|
|
* This script contains tests for the uncertainty helper.
|
2023-11-07 23:31:42 +01:00
|
|
|
*
|
|
|
|
* @covers \NodaUncertaintyHelper
|
2022-04-02 19:34:16 +02:00
|
|
|
*/
|
|
|
|
final class NodaUncertaintyHelperTest extends TestCase {
|
|
|
|
/**
|
|
|
|
* Removes uncertainty indicators from an time name.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
2022-04-02 19:34:16 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCleanUncertaintyIndicatorsTime():void {
|
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("wohl 1950"));
|
|
|
|
self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950"));
|
2022-04-02 19:34:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts guessing whether time is uncertain.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
2022-04-02 19:34:16 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testGuessTimeCertainty():void {
|
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertFalse(NodaUncertaintyHelper::guessTimeCertainty("wohl 1950"));
|
|
|
|
self::assertTrue(NodaUncertaintyHelper::guessTimeCertainty("1950"));
|
2022-04-02 19:34:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes uncertainty indicators from an place name.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
2022-04-02 19:34:16 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function testCleanUncertaintyIndicatorsPlace():void {
|
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertEquals("Berlin", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPlace("wohl Berlin"));
|
|
|
|
self::assertEquals("Berlin", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPlace("Berlin"));
|
|
|
|
|
|
|
|
// Real-life examples that previously passed unencumbered
|
|
|
|
self::assertEquals("Augsburg", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPlace("vermutlich: Augsburg"));
|
|
|
|
self::assertEquals("Augsburg", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPlace("vermutl. Augsburg"));
|
2022-04-02 19:34:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts guessing whether place is uncertain.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
2022-04-02 19:34:16 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function testGuessPlaceCertainty():void {
|
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("vermutlich: Augsburg"));
|
|
|
|
self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("vermutl. Augsburg"));
|
|
|
|
|
|
|
|
self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("wohl Berlin"));
|
|
|
|
self::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Berlin"));
|
2022-04-02 19:34:16 +02:00
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("?-Italien"));
|
2023-10-27 19:06:08 +02:00
|
|
|
|
2022-04-02 19:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes uncertainty indicators from an actor name.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
2022-04-02 19:34:16 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function testCleanUncertaintyIndicatorsPersinst():void {
|
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertEquals("Barbarossa", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPersinst("wohl Barbarossa"));
|
|
|
|
self::assertEquals("Barbarossa", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPersinst("Barbarossa"));
|
|
|
|
self::assertEquals("Barbarossa", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPersinst("?-Barbarossa"));
|
2022-04-02 19:34:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts guessing whether persinst is uncertain.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
2022-04-02 19:34:16 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function testGuessPersinstCertainty():void {
|
|
|
|
|
2023-11-18 01:36:01 +01:00
|
|
|
self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("wohl Barbarossa"));
|
|
|
|
self::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Barbarossa"));
|
2022-04-02 19:34:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|