MDNodaHelpers/tests/NodaTimeAutotranslaterTest.php

369 lines
10 KiB
PHP

<?PHP
/**
* This script contains tests for the home page.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
use PHPUnit\Framework\TestCase;
require __DIR__ . "/../src/NodaTimeAutotranslater.php";
/**
* Tests for home page.
*/
final class NodaTimeAutotranslaterTest extends TestCase {
/**
* Test to check whether the HTML page is correctly generated.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateCenturiesBeforeCommonEra():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateYYYYUntilYYYY():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateSingleYear():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateSingleYearBeforeCommonEra():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateYYYYUntilYYYYBefore1000():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateYYYYUntilYYYYBeforeCommonEra():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateSinceSingleDay():void {
$timeInfo = [
"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 <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testCanTranslateSinceSingleMonth():void {
$timeInfo = [
"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");
}
}