*/ declare(strict_types = 1); use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Small; /** * This script contains tests for the uncertainty helper. */ #[small] #[CoversClass(\NodaUncertaintyHelper::class)] final class NodaUncertaintyHelperTest extends TestCase { /** * Removes uncertainty indicators from an time name. * * @group ValidOutput * @small * * @return void */ public function testCleanUncertaintyIndicatorsTime():void { self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("wohl 1950")); self::assertEquals("1950", NodaUncertaintyHelper::cleanUncertaintyIndicatorsTime("1950")); } /** * Attempts guessing whether time is uncertain. * * @group ValidOutput * @small * * @return void */ public function testGuessTimeCertainty():void { self::assertFalse(NodaUncertaintyHelper::guessTimeCertainty("wohl 1950")); self::assertTrue(NodaUncertaintyHelper::guessTimeCertainty("1950")); } /** * Removes uncertainty indicators from an place name. * * @group ValidOutput * @small * * @return void */ public static function testCleanUncertaintyIndicatorsPlace():void { 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")); } /** * Attempts guessing whether place is uncertain. * * @group ValidOutput * @small * * @return void */ public static function testGuessPlaceCertainty():void { self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("vermutlich: Augsburg")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("vermutl. Augsburg")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("wohl Berlin")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("Berlin?")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("Berlin?,")); self::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Berlin,")); self::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Berlin")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("?-Italien")); } /** * Removes uncertainty indicators from an actor name. * * @group ValidOutput * @small * * @return void */ public static function testCleanUncertaintyIndicatorsPersinst():void { self::assertEquals("Barbarossa", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPersinst("wohl Barbarossa")); self::assertEquals("Barbarossa", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPersinst("Barbarossa")); self::assertEquals("Barbarossa", NodaUncertaintyHelper::cleanUncertaintyIndicatorsPersinst("?-Barbarossa")); } /** * Attempts guessing whether persinst is uncertain. * * @group ValidOutput * @small * * @return void */ public static function testGuessPersinstCertainty():void { self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("wohl Barbarossa")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("Barbarossa?")); self::assertFalse(NodaUncertaintyHelper::guessPlaceCertainty("Barbarossa?,")); self::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Barbarossa,")); self::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Barbarossa")); } }