*/ declare(strict_types = 1); use PHPUnit\Framework\TestCase; /** * This script contains tests for the automatic translation class for time names. * * @covers \NodaTimeAutotranslater */ final class NodaTimeAutotranslaterTest extends TestCase { /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleDay():void { $timeInfo = [ "zeit_beginn" => "1920", "zeit_ende" => "1920", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "01.05.1920"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleDayWith2DigitYear():void { $timeInfo = [ "zeit_beginn" => "20", "zeit_ende" => "20", "zeit_zaehlzeit_jahr" => "0020", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "01.05.20 n. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleDayWith2DigitYearBeforeCommonEra():void { $timeInfo = [ "zeit_beginn" => "-20", "zeit_ende" => "-20", "zeit_zaehlzeit_jahr" => "0020", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "01.05.20 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleDayBeforeCommonEra():void { $timeInfo = [ "zeit_beginn" => "-1920", "zeit_ende" => "-1920", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "01.05.1920 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleMonth():void { $timeInfo = [ "zeit_beginn" => "1920", "zeit_ende" => "1920", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "02", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Februar 1920"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleMonthBeforeCommonEra():void { $timeInfo = [ "zeit_beginn" => "-1920", "zeit_ende" => "-1920", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "02", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Februar 1920 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateDecade():void { $timeInfo = [ "zeit_beginn" => "1920", "zeit_ende" => "1929", "zeit_zaehlzeit_jahr" => "1925", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1920er Jahre"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateDecades():void { $timeInfo = [ "zeit_beginn" => "1920", "zeit_ende" => "1939", "zeit_zaehlzeit_jahr" => "1930", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1920-1930er Jahre"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testTranslateDecadeBeforeCommonEraAsTimespan():void { $timeInfo = [ "zeit_beginn" => "-10", "zeit_ende" => "-1", "zeit_zaehlzeit_jahr" => "0005", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "10-1 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testTranslateDecadeBeforeCommonEraAsTimespan4Digits():void { $timeInfo = [ "zeit_beginn" => "-1910", "zeit_ende" => "-1901", "zeit_zaehlzeit_jahr" => "0005", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1910-1901 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateCentury():void { $timeInfo = [ "zeit_beginn" => "1901", "zeit_ende" => "2000", "zeit_zaehlzeit_jahr" => "1950", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "20. Jahrhundert"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateCenturies():void { $timeInfo = [ "zeit_beginn" => "1801", "zeit_ende" => "2000", "zeit_zaehlzeit_jahr" => "1900", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "19.-20. Jahrhundert"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateCenturyBeforeCommonEra():void { $timeInfo = [ "zeit_beginn" => "-2000", "zeit_ende" => "-1901", "zeit_zaehlzeit_jahr" => "1950", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "20. Jahrhundert v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateCenturiesBeforeCommonEra():void { $timeInfo = [ "zeit_name" => "20.-19. Jahrhundert v. Chr.", "zeit_beginn" => "-2000", "zeit_ende" => "-1801", "zeit_zaehlzeit_jahr" => "1900", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "20.-19. Jahrhundert v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateYYYYUntilYYYY():void { $timeInfo = [ "zeit_name" => "1000-1150", "zeit_beginn" => "1000", "zeit_ende" => "1150", "zeit_zaehlzeit_jahr" => "1075", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1000-1150"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleYear():void { $timeInfo = [ "zeit_name" => "1000", "zeit_beginn" => "1000", "zeit_ende" => "1000", "zeit_zaehlzeit_jahr" => "1000", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1000"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleThreeDigitYearBeforeCommonEra():void { $timeInfo = [ "zeit_name" => "100 v. Chr.", "zeit_beginn" => "-100", "zeit_ende" => "-100", "zeit_zaehlzeit_jahr" => "100", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "100 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSingleYearBeforeCommonEra():void { $timeInfo = [ "zeit_name" => "1000 v. Chr.", "zeit_beginn" => "-1000", "zeit_ende" => "-1000", "zeit_zaehlzeit_jahr" => "1000", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1000 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateYYYYUntilYYYYBefore1000():void { $timeInfo = [ "zeit_name" => "800-850 n. Chr.", "zeit_beginn" => "800", "zeit_ende" => "850", "zeit_zaehlzeit_jahr" => "0825", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "800-850 n. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateYYYYUntilYYYYBeforeCommonEra():void { $timeInfo = [ "zeit_name" => "1156-1102 v. Chr.", "zeit_beginn" => "-1156", "zeit_ende" => "-1102", "zeit_zaehlzeit_jahr" => "1075", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "1156-1102 v. Chr."); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSinceSingleDay():void { $timeInfo = [ "zeit_name" => "Seit 01.05.1920", "zeit_beginn" => "1920", "zeit_ende" => "?", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Seit 01.05.1920"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateSinceSingleMonth():void { $timeInfo = [ "zeit_name" => "Seit Mai 1920", "zeit_beginn" => "1920", "zeit_ende" => "?", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Seit Mai 1920"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateAfterSingleYear():void { $timeInfo = [ "zeit_name" => "Nach 1919", "zeit_beginn" => "1920", "zeit_ende" => "?", "zeit_zaehlzeit_jahr" => "1919", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Nach 1919"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateAfterSingleMonth():void { $timeInfo = [ "zeit_name" => "Nach Mai 1920", "zeit_beginn" => "1920", "zeit_ende" => "?", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Nach Mai 1920"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateAfterSingleDay():void { $timeInfo = [ "zeit_name" => "Nach 01.12.1919", "zeit_beginn" => "1919", "zeit_ende" => "?", "zeit_zaehlzeit_jahr" => "1919", "zeit_zaehlzeit_monat" => "12", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Nach 01.12.1919"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateBeforeSingleYear():void { $timeInfo = [ "zeit_name" => "Vor 1919", "zeit_beginn" => "?", "zeit_ende" => "1918", "zeit_zaehlzeit_jahr" => "1919", "zeit_zaehlzeit_monat" => "00", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Vor 1919"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateBeforeSingleMonth():void { $timeInfo = [ "zeit_name" => "Vor Mai 1920", "zeit_beginn" => "?", "zeit_ende" => "1920", "zeit_zaehlzeit_jahr" => "1920", "zeit_zaehlzeit_monat" => "05", "zeit_zaehlzeit_tag" => "00", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Vor Mai 1920"); } /** * Test to check whether the HTML page is correctly generated. * * @author Joshua Ramon Enslin * @group ValidOutput * @small * * @return void */ public function testCanTranslateBeforeSingleDay():void { $timeInfo = [ "zeit_name" => "Vor 01.12.1919", "zeit_beginn" => "?", "zeit_ende" => "1919", "zeit_zaehlzeit_jahr" => "1919", "zeit_zaehlzeit_monat" => "12", "zeit_zaehlzeit_tag" => "01", ]; $output = NodaTimeAutotranslater::getTranslations($timeInfo); self::assertEquals($output["de"], "Vor 01.12.1919"); } }