MDNodaHelpers/tests/NodaUncertaintyHelperTest.php

116 lines
3.4 KiB
PHP
Raw Normal View History

<?PHP
/**
* This script contains tests for the uncertainty helper.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
use PHPUnit\Framework\TestCase;
/**
* This script contains tests for the uncertainty helper.
*
* @covers \NodaUncertaintyHelper
*/
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::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::assertTrue(NodaUncertaintyHelper::guessPlaceCertainty("Barbarossa"));
}
}