2020-09-26 14:15:15 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
2022-05-17 23:27:40 +02:00
|
|
|
* This script contains tests for the time name splitter.
|
2020-09-26 14:15:15 +02:00
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
2022-05-17 23:27:40 +02:00
|
|
|
* This script contains tests for the time name splitter.
|
2023-11-07 23:31:42 +01:00
|
|
|
*
|
|
|
|
* @covers \NodaTimeSplitter
|
2020-09-26 14:15:15 +02:00
|
|
|
*/
|
|
|
|
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
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
2020-09-26 15:10:06 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitSimpleDatesGerman():void {
|
|
|
|
|
2024-04-16 23:21:34 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2. Januar 2020");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
|
2020-09-26 16:02:18 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("02.1.25 v. Chr");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 16:02:18 +02:00
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.25 v. Chr.");
|
2020-09-26 16:02:18 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2.01.25 v. Chr");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 16:02:18 +02:00
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.25 v. Chr.");
|
2020-09-26 16:02:18 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("02.01.25 v. Chr");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 16:02:18 +02:00
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.25 v. Chr.");
|
2020-09-26 16:02:18 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2.1.25 v. Chr");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 16:02:18 +02:00
|
|
|
0 => "-25",
|
|
|
|
1 => "-25",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.25 v. Chr.");
|
2020-09-26 16:02:18 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 25);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2.1.2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("02.01.2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-1929");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2020-09-27 17:12:34 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20er");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-27 17:12:34 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1920-1929");
|
2020-09-27 17:12:34 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-1929");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-11-20 03:18:02 +01:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1920-1929");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920er Jahre");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
2020-10-04 19:27:23 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Vor Dezember 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-04 19:27:23 +02:00
|
|
|
0 => "?",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "12",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Vor",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Vor Dezember 2020");
|
2020-10-04 19:27:23 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Vor 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-04 19:27:23 +02:00
|
|
|
0 => "?",
|
|
|
|
1 => "2019",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Vor",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Vor 2020");
|
2020-10-04 19:27:23 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2020-10-04 19:17:18 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Nach Januar 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-04 19:17:18 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "?",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Nach",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Nach Januar 2020");
|
2020-10-04 19:17:18 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2022-04-12 23:47:08 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-04-12 23:47:08 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 2020");
|
2022-04-12 23:47:08 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 1217");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-04-12 23:47:08 +02:00
|
|
|
0 => "1217",
|
|
|
|
1 => "1217",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2022-11-03 16:02:10 +01:00
|
|
|
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 1217");
|
2022-04-12 23:47:08 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1217);
|
|
|
|
|
2022-11-03 16:02:10 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 1520");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-11-03 16:02:10 +01:00
|
|
|
0 => "1520",
|
|
|
|
1 => "1520",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 1520");
|
2022-11-03 16:02:10 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1520);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 1001");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-11-03 16:02:10 +01:00
|
|
|
0 => "1001",
|
|
|
|
1 => "1001",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 1001");
|
2022-11-03 16:02:10 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1001);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2780");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-11-03 16:02:10 +01:00
|
|
|
0 => "2780",
|
|
|
|
1 => "2780",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
|
|
|
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 2780");
|
2022-11-03 16:02:10 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2780);
|
|
|
|
|
2020-10-04 19:17:18 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Nach 60er Jahre");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-04 19:17:18 +02:00
|
|
|
0 => "1970",
|
|
|
|
1 => "?",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Nach",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Nach 1969");
|
2020-10-04 19:17:18 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1969);
|
|
|
|
|
2020-10-04 17:39:34 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Nach 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-04 17:39:34 +02:00
|
|
|
0 => "2021",
|
|
|
|
1 => "?",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Nach",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Nach 2020");
|
2020-10-04 17:39:34 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Bis Januar 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-04 17:39:34 +02:00
|
|
|
0 => "?",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Bis",
|
2020-10-04 17:39:34 +02:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Bis Januar 2020");
|
2020-10-04 17:39:34 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2020");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
2020-09-27 17:10:17 +02:00
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 2020");
|
2020-09-27 17:10:17 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
// Intl' month: 2020-01
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020-01");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-27 17:10:17 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
2020-09-26 15:10:06 +02:00
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 2020");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar 2020 v. Chr.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "-2020",
|
|
|
|
1 => "-2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Januar 2020 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
// 5-Digit timespans BCE
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("40000-25000 vor Christus");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "-40000",
|
|
|
|
1 => "-25000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "40000-25000 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 32500);
|
|
|
|
|
2024-03-24 00:59:30 +01:00
|
|
|
// 5-Digit timespans BCE
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("40000-25000 v.C.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2024-03-24 00:59:30 +01:00
|
|
|
0 => "-40000",
|
|
|
|
1 => "-25000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "40000-25000 v. Chr.");
|
2024-03-24 00:59:30 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 32500);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jahrhundert v. Chr.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1901",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "2000-1901 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1950);
|
|
|
|
|
2022-03-12 19:32:28 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jh.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-03-12 19:32:28 +01:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2022-03-12 19:32:28 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jhd.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-03-12 19:32:28 +01:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2022-03-12 19:32:28 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jhdt.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-03-12 19:32:28 +01:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2022-03-12 19:32:28 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. Jahrhundert");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-03-12 19:32:28 +01:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2022-03-12 19:32:28 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20.-19. Jahrhundert v. Chr.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "2000-1801 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1900);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Bis 20.-19. Jahrhundert v. Chr.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 15:10:06 +02:00
|
|
|
0 => "?",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Bis",
|
2020-09-26 15:10:06 +02:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Bis 1801 v. Chr.");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1801);
|
|
|
|
|
2022-09-08 16:28:27 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("6 November 1978");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2022-09-08 16:28:27 +02:00
|
|
|
0 => "1978",
|
|
|
|
1 => "1978",
|
|
|
|
2 => "11",
|
|
|
|
3 => "06",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "06.11.1978");
|
2022-09-08 16:28:27 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1978);
|
|
|
|
|
2020-09-26 15:10:06 +02:00
|
|
|
}
|
|
|
|
|
2023-10-15 19:20:16 +02:00
|
|
|
/**
|
|
|
|
* Test to check whether the HTML page is correctly generated.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
2023-10-15 19:20:16 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitSimpleDatesEnglish():void {
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1925 BCE");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-10-15 19:20:16 +02:00
|
|
|
0 => "-1925",
|
|
|
|
1 => "-1925",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1925 v. Chr.");
|
2023-10-15 19:20:16 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1925 CE");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-10-15 19:20:16 +02:00
|
|
|
0 => "1925",
|
|
|
|
1 => "1925",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1925");
|
2023-10-15 19:20:16 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
2020-09-26 14:15:15 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitSimpleDatesHungarian():void {
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020.01.02.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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
|
|
|
|
2023-12-09 23:54:45 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020. januar. 2.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-12-09 23:54:45 +01:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
2023-12-09 23:54:45 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020.01.2.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-11-20 03:18:02 +01:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020.1.2.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-11-20 03:18:02 +01:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020. Januar 2.");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "02.01.2020");
|
2020-09-27 12:40:15 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020-01-02");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-27 12:40:15 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "02",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
// From 1920 onwards
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920 utántól");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-11-20 03:18:02 +01:00
|
|
|
0 => "1920",
|
|
|
|
1 => "?",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Seit",
|
2023-11-20 03:18:02 +01:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Seit 1920");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1920);
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-es évek");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "1920",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1920-1929");
|
2020-09-26 15:10:06 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1925);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
2023-12-09 23:54:45 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1920-es évekig");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-12-09 23:54:45 +01:00
|
|
|
0 => "?",
|
|
|
|
1 => "1929",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Bis",
|
2023-12-09 23:54:45 +01:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Bis 1929");
|
2023-12-09 23:54:45 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1929);
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020. Januar");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
2023-12-09 11:56:15 +01:00
|
|
|
self::assertEquals([
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
2024-04-16 23:21:34 +02:00
|
|
|
], $output->toOldFormat());
|
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "-2020",
|
|
|
|
1 => "-2020",
|
|
|
|
2 => "01",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-03 15:59:49 +02:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2020-10-03 15:59:49 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-10-03 16:10:43 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("III. század");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-03 16:10:43 +02:00
|
|
|
0 => "201",
|
|
|
|
1 => "300",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "201-300 n. Chr.");
|
2020-10-03 16:10:43 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 251);
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20th century");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-11-20 03:18:02 +01:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-10-03 15:59:49 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20. század");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-10-03 15:59:49 +02:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2020-10-03 15:59:49 +02:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("20.század");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-11-20 03:18:02 +01:00
|
|
|
0 => "1901",
|
|
|
|
1 => "2000",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "1901-2000");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1951);
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Kr. e. 20. század");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1901",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "-2000",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2020-09-26 14:15:15 +02:00
|
|
|
0 => "?",
|
|
|
|
1 => "-1801",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "-",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Bis",
|
2020-09-26 14:15:15 +02:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "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
|
|
|
|
2023-12-09 11:56:15 +01:00
|
|
|
/*
|
|
|
|
* TODO
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1900 előtt");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-12-09 11:56:15 +01:00
|
|
|
0 => "?",
|
|
|
|
1 => "1899",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Vor 1900");
|
2023-12-09 11:56:15 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1899);
|
|
|
|
*/
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1900-ig");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-12-09 11:56:15 +01:00
|
|
|
0 => "?",
|
|
|
|
1 => "1900",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Bis",
|
2023-12-09 11:56:15 +01:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Bis 1900");
|
2023-12-09 11:56:15 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1900);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1900ig");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-12-09 11:56:15 +01:00
|
|
|
0 => "?",
|
|
|
|
1 => "1900",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
2024-04-16 23:21:34 +02:00
|
|
|
5 => "Bis",
|
2023-12-09 11:56:15 +01:00
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Bis 1900");
|
2023-12-09 11:56:15 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 1900);
|
|
|
|
|
2023-12-09 23:54:45 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020. december előtt");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2023-12-09 23:54:45 +01:00
|
|
|
0 => "?",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "12",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "Vor",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "Vor Dezember 2020");
|
2023-12-09 23:54:45 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
}
|
|
|
|
|
2024-03-24 00:59:30 +01:00
|
|
|
/**
|
|
|
|
* Test to check whether the HTML page is correctly generated.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitSimpleDatesUkrainian():void {
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020 p");
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output->toOldFormat(), [
|
2024-03-24 00:59:30 +01:00
|
|
|
0 => "2020",
|
|
|
|
1 => "2020",
|
|
|
|
2 => "00",
|
|
|
|
3 => "00",
|
|
|
|
4 => "+",
|
|
|
|
5 => "",
|
|
|
|
]);
|
2024-04-16 23:21:34 +02:00
|
|
|
self::assertEquals($output->toTimeName(), "2020");
|
2024-03-24 00:59:30 +01:00
|
|
|
self::assertEquals(NodaTimeSplitter::timePartsToCountingYear($output), 2020);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
/**
|
|
|
|
* Test to check special cases can be parsed.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
* @small
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplittingFromTill():void {
|
|
|
|
|
|
|
|
// Regular
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("2004.01.-2004.02.");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output, [
|
|
|
|
'start_name' => "Januar 2004",
|
|
|
|
'end_name' => "Februar 2004",
|
|
|
|
"start_year" => '2004',
|
|
|
|
"end_year" => '2004',
|
2024-05-04 01:17:33 +02:00
|
|
|
'start_date' => '2004-01-01',
|
|
|
|
'end_date' => '2004-02-31',
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_year" => "2004",
|
2024-04-16 23:21:34 +02:00
|
|
|
"counting_time_month" => "02",
|
|
|
|
"counting_time_day" => "01",
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_bcce" => "+",
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Rewritten / Hungarian YYYY.MM.-MM.
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("2004.01.-02.");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output, [
|
|
|
|
'start_name' => "Januar 2004",
|
|
|
|
'end_name' => "Februar 2004",
|
|
|
|
"start_year" => '2004',
|
|
|
|
"end_year" => '2004',
|
2024-05-04 01:17:33 +02:00
|
|
|
'start_date' => '2004-01-01',
|
|
|
|
'end_date' => '2004-02-31',
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_year" => "2004",
|
2024-04-16 23:21:34 +02:00
|
|
|
"counting_time_month" => "02",
|
|
|
|
"counting_time_day" => "01",
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_bcce" => "+",
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Rewritten / Hungarian YYYY.MM.-MM.
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("2003.04-05.");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
|
|
|
|
// Rewritten / Hungarian YYYY.MM.-MM.
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("1981. július-augusztus");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("2019.03.14.,04.15.");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output, [
|
|
|
|
'start_name' => "14.03.2019",
|
|
|
|
'end_name' => "15.04.2019",
|
|
|
|
"start_year" => '2019',
|
|
|
|
"end_year" => '2019',
|
2024-05-04 01:17:33 +02:00
|
|
|
'start_date' => '2019-03-14',
|
|
|
|
'end_date' => '2019-04-15',
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_year" => "2019",
|
|
|
|
"counting_time_month" => "03",
|
|
|
|
"counting_time_day" => "30",
|
|
|
|
"counting_time_bcce" => "+",
|
|
|
|
]);
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("2019.03.14-15");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output, [
|
|
|
|
'start_name' => "14.03.2019",
|
|
|
|
'end_name' => "15.03.2019",
|
|
|
|
"start_year" => '2019',
|
|
|
|
"end_year" => '2019',
|
2024-05-04 01:17:33 +02:00
|
|
|
'start_date' => '2019-03-14',
|
|
|
|
'end_date' => '2019-03-15',
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_year" => "2019",
|
|
|
|
"counting_time_month" => "03",
|
|
|
|
"counting_time_day" => "15",
|
|
|
|
"counting_time_bcce" => "+",
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Rewritten / Hungarian YYYY.MM.-MM.
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("17-19.század");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output, [
|
|
|
|
'start_name' => "1601",
|
|
|
|
'end_name' => "1900",
|
|
|
|
"start_year" => '1601',
|
|
|
|
"end_year" => '1900',
|
2024-05-04 01:17:33 +02:00
|
|
|
'start_date' => '1601-01-01',
|
|
|
|
'end_date' => '1900-12-31',
|
2024-04-16 23:21:34 +02:00
|
|
|
"counting_time_year" => "1751",
|
|
|
|
"counting_time_month" => "01",
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_day" => "01",
|
|
|
|
"counting_time_bcce" => "+",
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Rewritten / 1950-60-as évek
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting_from_till("1950-60-as évek");
|
|
|
|
self::assertNotEmpty($output);
|
|
|
|
self::assertEquals($output, [
|
|
|
|
'start_name' => "1950",
|
|
|
|
'end_name' => "1969",
|
|
|
|
"start_year" => '1950',
|
|
|
|
"end_year" => '1969',
|
2024-05-04 01:17:33 +02:00
|
|
|
'start_date' => '1950-01-01',
|
|
|
|
'end_date' => '1969-12-31',
|
2024-04-16 23:21:34 +02:00
|
|
|
"counting_time_year" => "1960",
|
|
|
|
"counting_time_month" => "01",
|
2023-11-20 03:18:02 +01:00
|
|
|
"counting_time_day" => "01",
|
|
|
|
"counting_time_bcce" => "+",
|
|
|
|
]);
|
|
|
|
|
2024-05-04 01:17:33 +02:00
|
|
|
// Rewritten / 1950-60-as évek
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1400-1100 v. Chr.");
|
2024-05-05 22:54:33 +02:00
|
|
|
self::assertNotEmpty($output);
|
2024-05-04 01:17:33 +02:00
|
|
|
self::assertEquals('-1400', $output->start_year);
|
|
|
|
self::assertEquals('-1400-01-01', $output->start_date);
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
}
|
|
|
|
|
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
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
2020-09-26 14:15:15 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitDoesNotWorkWhenItShouldNot():void {
|
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1.2.2020-2.2.2020");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020 Januar 2-2020 Februar 2");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2020 Januar-2020 Februar");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Januar-Februar");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2020-09-26 14:15:15 +02:00
|
|
|
|
2022-08-25 22:06:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("13.13.2022");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2022-08-25 22:06:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2022-13-13");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2022-08-25 22:06:15 +02:00
|
|
|
|
|
|
|
$output = NodaTimeSplitter::attempt_splitting("40.10.2022");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2022-08-25 22:06:15 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("2022-10-40");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2022-08-25 22:06:15 +02:00
|
|
|
|
2022-09-08 16:28:27 +02:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("6;November 1978");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2022-09-08 16:28:27 +02:00
|
|
|
|
2023-11-07 00:27:20 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("65497028c51eb");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
2023-11-14 03:32:17 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("6552cf08b0196 test tag");
|
2023-11-20 03:18:02 +01:00
|
|
|
self::assertEmpty($output);
|
|
|
|
|
2023-12-08 12:26:59 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1978. július7");
|
|
|
|
self::assertEmpty($output);
|
|
|
|
|
2023-12-09 11:56:15 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("1978. július 7 elött");
|
|
|
|
self::assertEmpty($output);
|
|
|
|
|
2023-11-20 03:18:02 +01:00
|
|
|
$output = NodaTimeSplitter::attempt_splitting("Anfang September 1903");
|
|
|
|
self::assertEmpty($output);
|
2023-11-07 00:27:20 +01:00
|
|
|
|
2020-10-04 19:17:18 +02:00
|
|
|
# $output = NodaTimeSplitter::attempt_splitting("Nach 1944-1964");
|
2023-11-20 03:18:02 +01:00
|
|
|
# self::assertEmpty($output);
|
2020-09-26 15:10:06 +02:00
|
|
|
|
2020-09-26 14:15:15 +02:00
|
|
|
}
|
|
|
|
}
|