mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-29 17:28:41 +00:00
fix tests
This commit is contained in:
parent
ab7b467c1d
commit
bf9d528076
|
|
@ -43,28 +43,28 @@ class ICalParser
|
||||||
$event = [];
|
$event = [];
|
||||||
|
|
||||||
\preg_match('/UID:(.*?)\n/', $match[1], $uidMatch);
|
\preg_match('/UID:(.*?)\n/', $match[1], $uidMatch);
|
||||||
$event['uid'] = \DateTime::createFromFormat('Ymd\THis', $uidMatch[1] ?? '');
|
$event['uid'] = $uidMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/STATUS:(.*?)\n/', $match[1], $statusMatch);
|
\preg_match('/STATUS:(.*?)\n/', $match[1], $statusMatch);
|
||||||
$event['status'] = \DateTime::createFromFormat('Ymd\THis', $statusMatch[1] ?? '');
|
$event['status'] = $statusMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/DTSTART:(.*?)\n/', $match[1], $startMatch);
|
\preg_match('/DTSTART:(.*?)\n/', $match[1], $startMatch);
|
||||||
$event['start'] = \DateTime::createFromFormat('Ymd\THis', $startMatch[1] ?? '');
|
$event['start'] = $startMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/DTEND:(.*?)\n/', $match[1], $endMatch);
|
\preg_match('/DTEND:(.*?)\n/', $match[1], $endMatch);
|
||||||
$event['end'] = \DateTime::createFromFormat('Ymd\THis', $endMatch[1] ?? '');
|
$event['end'] = $endMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/ORGANIZER:(.*?)\n/', $match[1], $organizerMatch);
|
\preg_match('/ORGANIZER:(.*?)\n/', $match[1], $organizerMatch);
|
||||||
$event['organizer'] = $organizerMatch[1] ?? '';
|
$event['organizer'] = $organizerMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/SUMMARY:(.*?)\n/', $match[1], $summaryMatch);
|
\preg_match('/SUMMARY:(.*?)\n/', $match[1], $summaryMatch);
|
||||||
$event['summary'] = $summaryMatch[1] ?? '';
|
$event['summary'] = $summaryMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/DESCRIPTION:(.*?)\n/', $match[1], $descriptionMatch);
|
\preg_match('/DESCRIPTION:(.*?)\n/', $match[1], $descriptionMatch);
|
||||||
$event['description'] = $descriptionMatch[1] ?? '';
|
$event['description'] = $descriptionMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/LOCATION:(.*?)\n/', $match[1], $locationMatch);
|
\preg_match('/LOCATION:(.*?)\n/', $match[1], $locationMatch);
|
||||||
$event['location'] = $locationMatch[1] ?? '';
|
$event['location'] = $locationMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/GEO:(.*?)\n/', $match[1], $geo);
|
\preg_match('/GEO:(.*?)\n/', $match[1], $geo);
|
||||||
$temp = \explode(';', $geo[1]);
|
$temp = \explode(';', $geo[1]);
|
||||||
|
|
@ -74,7 +74,7 @@ class ICalParser
|
||||||
];
|
];
|
||||||
|
|
||||||
\preg_match('/URL:(.*?)\n/', $match[1], $url);
|
\preg_match('/URL:(.*?)\n/', $match[1], $url);
|
||||||
$event['url'] = $url[1] ?? '';
|
$event['url'] = $url[1] ?? null;
|
||||||
|
|
||||||
// Check if this event is recurring
|
// Check if this event is recurring
|
||||||
if (\preg_match('/RRULE:(.*?)\n/', $match[1], $rruleMatch)) {
|
if (\preg_match('/RRULE:(.*?)\n/', $match[1], $rruleMatch)) {
|
||||||
|
|
@ -102,17 +102,27 @@ class ICalParser
|
||||||
$rrule = [];
|
$rrule = [];
|
||||||
|
|
||||||
\preg_match('/FREQ=(.*?);/', $rruleString, $freqMatch);
|
\preg_match('/FREQ=(.*?);/', $rruleString, $freqMatch);
|
||||||
$rrule['freq'] = $freqMatch[1] ?? '';
|
$rrule['freq'] = $freqMatch[1] ?? null;
|
||||||
|
|
||||||
\preg_match('/INTERVAL=(.*?);/', $rruleString, $intervalMatch);
|
\preg_match('/INTERVAL=(.*?);/', $rruleString, $intervalMatch);
|
||||||
$rrule['interval'] = (int) ($intervalMatch[1] ?? 0);
|
$rrule['interval'] = $intervalMatch[1] ?? null;
|
||||||
|
|
||||||
|
\preg_match('/BYMONTH=(.*?);/', $rruleString, $monthMatch);
|
||||||
|
$rrule['bymonth'] = $monthMatch[1] ?? null;
|
||||||
|
|
||||||
|
\preg_match('/BYMONTHDAY=(.*?);/', $rruleString, $monthdayMatch);
|
||||||
|
$rrule['bymonthday'] = $monthdayMatch[1] ?? null;
|
||||||
|
|
||||||
if (\preg_match('/COUNT=(.*?);/', $rruleString, $countMatch)) {
|
if (\preg_match('/COUNT=(.*?);/', $rruleString, $countMatch)) {
|
||||||
$rrule['count'] = (int) ($countMatch[1] ?? 0);
|
$rrule['count'] = (int) ($countMatch[1] ?? 0);
|
||||||
|
} else {
|
||||||
|
$rrule['count'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\preg_match('/UNTIL=(.*?);/', $rruleString, $untilMatch)) {
|
if (\preg_match('/UNTIL=(.*?);/', $rruleString, $untilMatch)) {
|
||||||
$rrule['until'] = \DateTime::createFromFormat('Ymd\THis', $untilMatch[1] ?? '');
|
$rrule['until'] = $untilMatch[1] ?? null;
|
||||||
|
} else {
|
||||||
|
$rrule['until'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rrule;
|
return $rrule;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,16 @@ final class BinarySearchTreeTest extends \PHPUnit\Framework\TestCase
|
||||||
$bst->insert(new Node('A', 'A'));
|
$bst->insert(new Node('A', 'A'));
|
||||||
$bst->insert(new Node('U', 'U'));
|
$bst->insert(new Node('U', 'U'));
|
||||||
$bst->insert(new Node('R', 'R'));
|
$bst->insert(new Node('R', 'R'));
|
||||||
|
|
||||||
|
self::assertEquals(
|
||||||
|
[
|
||||||
|
'key' => 'D',
|
||||||
|
0 => ['key' => 'I'],
|
||||||
|
1 => ['key' => 'I'],
|
||||||
|
],
|
||||||
|
$bst->toArray()
|
||||||
|
);
|
||||||
|
|
||||||
$bst->delete($bst->search('I'));
|
$bst->delete($bst->search('I'));
|
||||||
$bst->insert(new Node('Z', 'Z'));
|
$bst->insert(new Node('Z', 'Z'));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,18 @@
|
||||||
"status": "CONFIRMED",
|
"status": "CONFIRMED",
|
||||||
"start": "20080212",
|
"start": "20080212",
|
||||||
"end": "20080213",
|
"end": "20080213",
|
||||||
"organizer": "",
|
"organizer": null,
|
||||||
"summary": "Abraham Lincoln",
|
"summary": "Abraham Lincoln",
|
||||||
"description": "Born February 12, 1809\nSixteenth President (1861-1865)\n\n\n\nhttp://AmericanHistoryCalendar.com",
|
"description": "Born February 12, 1809\nSixteenth President (1861-1865)\\n\\n\\n\\nhttp://AmericanHistoryCalendar.com",
|
||||||
"location": "Hodgenville, Kentucky",
|
"location": "Hodgenville, Kentucky",
|
||||||
"geo": {
|
"geo": {
|
||||||
"lat": -85.7399606,
|
"lat": 37.5739497,
|
||||||
"lon": 37.5739497
|
"lon": -85.7399606
|
||||||
},
|
},
|
||||||
"url": "http://americanhistorycalendar.com/peoplecalendar/1,328-abraham-lincoln",
|
"url": "http://americanhistorycalendar.com/peoplecalendar/1,328-abraham-lincoln",
|
||||||
"freq": "YEARLY",
|
"freq": "YEARLY",
|
||||||
"interval": "1",
|
"interval": "1",
|
||||||
"count": "",
|
"count": null,
|
||||||
"until": ""
|
"until": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -50,7 +50,10 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
||||||
$parser = new Markdown();
|
$parser = new Markdown();
|
||||||
$parser->setSafeMode(true);
|
$parser->setSafeMode(true);
|
||||||
|
|
||||||
self::assertTrue(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.html') === ($parsed = $parser->text(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.md'))), $parsed);
|
self::assertEquals(
|
||||||
|
\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.html'),
|
||||||
|
$parser->text(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.md'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTablespan() : void
|
public function testTablespan() : void
|
||||||
|
|
@ -61,7 +64,10 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::assertTrue(\file_get_contents(__DIR__ . '/manualdata/tablespan.html') === ($parsed = $parser->text(\file_get_contents(__DIR__ . '/manualdata/tablespan.md'))), $parsed);
|
self::assertEquals(
|
||||||
|
\file_get_contents(__DIR__ . '/manualdata/tablespan.html'),
|
||||||
|
$parser->text(\file_get_contents(__DIR__ . '/manualdata/tablespan.md'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMath() : void
|
public function testMath() : void
|
||||||
|
|
@ -70,7 +76,10 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
||||||
'math' => true
|
'math' => true
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::assertTrue(\file_get_contents(__DIR__ . '/manualdata/katex.html') === ($parsed = $parser->text(\file_get_contents(__DIR__ . '/manualdata/katex.md'))), $parsed);
|
self::assertEquals(
|
||||||
|
\file_get_contents(__DIR__ . '/manualdata/katex.html'),
|
||||||
|
$parser->text(\file_get_contents(__DIR__ . '/manualdata/katex.md'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTOC() : void
|
public function testTOC() : void
|
||||||
|
|
@ -79,7 +88,10 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase
|
||||||
'toc' => true
|
'toc' => true
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self::assertTrue(\file_get_contents(__DIR__ . '/manualdata/toc.html') === ($parsed = $parser->text(\file_get_contents(__DIR__ . '/manualdata/toc.md'))), $parsed);
|
self::assertEquals(
|
||||||
self::assertTrue('' === $parser->contentsList());
|
\file_get_contents(__DIR__ . '/manualdata/toc.html'),
|
||||||
|
$parser->text(\file_get_contents(__DIR__ . '/manualdata/toc.md'))
|
||||||
|
);
|
||||||
|
self::assertEquals('', $parser->contentsList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user