Changes for tests/src/Kernel/CalendarLinkTwigExtensionTest.php: 29 added lines, 6 removed lines.
Original line number
Diff line number
Diff line
@@ -53,16 +53,14 @@ class CalendarLinkTwigExtensionTest extends KernelTestBase {
/**
* Tests the "calendar_link" Twig function.
*
* @dataProvider calendarLinkDataProvider
*/
publicfunctiontestCalendarLinkFunction(){
$template="{% set title = 'title'|t %}{% set startDate = date('2019-02-24 10:00', 'Etc/UTC') %}{% set endDate = date('2019-02-24 12:00', 'Etc/UTC') %}{% set link = calendar_link('ics', title, startDate, endDate, false, 'description', 'location') %}<a href=\"{{ link }}\">Add to calendar</a>";
$expected_template_output='<a href="data:text/calendar;charset=utf8;base64,QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KQkVHSU46VkVWRU5UDQpVSUQ6YTc4ZDRjM2NjNzA3YzRjZGU3NjBiYWQzZmJmZjhlYTENClNVTU1BUlk6dGl0bGUNCkRUU1RBUlQ7VFpJRD1FdGMvVVRDOjIwMTkwMjIzVDIzMDAwMA0KRFRFTkQ7VFpJRD1FdGMvVVRDOjIwMTkwMjI0VDAxMDAwMA0KREVTQ1JJUFRJT046ZGVzY3JpcHRpb24NCkxPQ0FUSU9OOmxvY2F0aW9uDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFS">Add to calendar</a>';
* @todo Add render array and field item object tests.
*/
publicfunctioncalendarLinkDataProvider():array{
return[
// Dates as simple objects.
[
"{% set title = 'title'|t %}{% set startDate = date('2019-02-24 10:00', 'Etc/UTC') %}{% set endDate = date('2019-02-24 12:00', 'Etc/UTC') %}{% set link = calendar_link('ics', title, startDate, endDate, false, 'description', 'location') %}<a href=\"{{ link }}\">Add to calendar</a>",
'<a href="data:text/calendar;charset=utf8;base64,QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KQkVHSU46VkVWRU5UDQpVSUQ6YTc4ZDRjM2NjNzA3YzRjZGU3NjBiYWQzZmJmZjhlYTENClNVTU1BUlk6dGl0bGUNCkRUU1RBUlQ7VFpJRD1FdGMvVVRDOjIwMTkwMjIzVDIzMDAwMA0KRFRFTkQ7VFpJRD1FdGMvVVRDOjIwMTkwMjI0VDAxMDAwMA0KREVTQ1JJUFRJT046ZGVzY3JpcHRpb24NCkxPQ0FUSU9OOmxvY2F0aW9uDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFS">Add to calendar</a>',
],
// Dates as `<time>` HTML elements (Views behavior).
[
"{% set link = calendar_link('yahoo', 'title', '<time datetime=\"2022-03-21T16:00:00Z\" class=\"datetime\">Mon, 03/21/2022 - 09:00</time>', '<time datetime=\"2022-03-26T00:00:00Z\" class=\"datetime\">Fri, 03/25/2022 - 17:00</time>', false, 'description', 'location') %}<a href=\"{{ link }}\">Add to calendar</a>",
'<a href="https://calendar.yahoo.com/?v=60&view=d&type=20&ST=20220321T160000Z&ET=20220326T000000Z&TITLE=title&DESC=description&in_loc=location">Add to calendar</a>',