2020-09-26 14:15:15 +02:00
|
|
|
<?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_once __DIR__ . "/../src/NodaTimeSplitter.php";
|
2022-03-12 19:32:28 +01:00
|
|
|
require_once __DIR__ . "/../src/NodaTimeAutotranslater.php";
|
2021-03-09 20:15:22 +01:00
|
|
|
require_once __DIR__ . "/../../MD_STD/src/MD_STD.php";
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests for home page.
|
|
|
|
*/
|
|
|
|
final class NodaTimeSplitterTest extends TestCase {
|
2020-09-26 15:10:06 +02:00
|
|
|
/**
|
|
|
|
* Test to check whether the HTML page is correctly generated.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitSimpleDatesGerman():void {
|
|
|
|
|
2020-09-26 16:02:18 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("02.1.25 v. Chr");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2.01.25 v. Chr");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("02.01.25 v. Chr");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2.1.25 v. Chr");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.25 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2.1.2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("02.01.2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2. Januar 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-1929");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2020-09-27 17:12:34 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20er");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920er Jahre");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2020-10-04 19:27:23 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Vor Dezember 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "?",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "12",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Vor",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Vor Dezember 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Vor 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "?",
|
|
|
|
1 => "2019",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Vor",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Vor 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2020-10-04 19:17:18 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Nach Januar 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "?",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Nach",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Nach Januar 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2022-04-12 23:47:08 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 1217");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1217",
|
|
|
|
1 => "1217",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 1217");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1217);
|
|
|
|
|
2020-10-04 19:17:18 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Nach 60er Jahre");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1970",
|
|
|
|
1 => "?",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Nach",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Nach 1969");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1969);
|
|
|
|
|
2020-10-04 17:39:34 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Nach 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2021",
|
|
|
|
1 => "?",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Nach",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Nach 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Bis Januar 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "?",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Bis Januar 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2020");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
2020-09-27 17:10:17 +02:00
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
// Intl' month: 2020-01
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020-01");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
2020-09-26 15:10:06 +02:00
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2020 v. Chr.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-2020",
|
|
|
|
1 => "-2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
// 5-Digit timespans BCE
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("40000-25000 vor Christus");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-40000",
|
|
|
|
1 => "-25000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "40000-25000 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 32500);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jahrhundert v. Chr.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1901",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "2000-1901 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1950);
|
|
|
|
|
2022-03-12 19:32:28 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jh.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jhd.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jhdt.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jahrhundert");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20.-19. Jahrhundert v. Chr.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "2000-1801 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1900);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Bis 20.-19. Jahrhundert v. Chr.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "?",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Bis 1801 v. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1801);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
/**
|
|
|
|
* Test to check whether the HTML page is correctly generated.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitSimpleDatesHungarian():void {
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020.01.02.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.2020");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020. Januar 2.");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.2020");
|
2020-09-27 12:40:15 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020-01-02");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "02.01.2020");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-tól 1929-ig");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-1929 között");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-től 1929-ig");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-es évek");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020. Januar");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Kr. e. 2020. Januar");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-2020",
|
|
|
|
1 => "-2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Januar 2020 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
2020-10-03 15:59:49 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. sz");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-10-03 16:10:43 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("III. század");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "201",
|
|
|
|
1 => "300",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "201-300 n. Chr.");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 251);
|
|
|
|
|
2020-10-03 15:59:49 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. század");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "1901-2000");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Kr. e. 20. század");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1901",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "2000-1901 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1950);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Kr. e. 20.-19. század");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "2000-1801 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1900);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Kr. e. 20.-19. század-ig");
|
|
|
|
self::assertEquals($output, [
|
|
|
|
0 => "?",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToTimeName($output), "Bis 1801 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1801);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test to check whether the HTML page is correctly generated.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitDoesNotWorkWhenItShouldNot():void {
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("");
|
|
|
|
self::assertEquals($output, []);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1.2.2020-2.2.2020");
|
|
|
|
self::assertEquals($output, []);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020 Januar 2-2020 Februar 2");
|
|
|
|
self::assertEquals($output, []);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020 Januar-2020 Februar");
|
|
|
|
self::assertEquals($output, []);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar-Februar");
|
|
|
|
self::assertEquals($output, []);
|
|
|
|
|
2020-10-04 19:17:18 +02:00
|
|
|
# $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964");
|
|
|
|
# self::assertEquals($output, []);
|
2020-09-26 15:10:06 +02:00
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
}
|
|
|
|
}
|