From 5589fcf71b4f40775a3152cf31e0f3f4ed80dfee Mon Sep 17 00:00:00 2001 From: Matthias Huber Date: Fri, 15 Mar 2019 15:42:35 +0100 Subject: [PATCH 1/3] add unit test for issue 196, reading ics file with exceptions to recurrence rule --- tests/RecurrencesTest.php | 21 +++++++++++++ tests/issue196.txt | 64 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/issue196.txt diff --git a/tests/RecurrencesTest.php b/tests/RecurrencesTest.php index 9b9ac57..7653c2a 100644 --- a/tests/RecurrencesTest.php +++ b/tests/RecurrencesTest.php @@ -78,6 +78,25 @@ public function testMonthlyFullDayTimeZoneBerlinFromFile() { $checks); } + /** + * @runInSeparateProcess + */ + public function testIssue196FromFile() { + $checks = array( + array('index' => 0, 'dateString' => '20191105T190000', 'timezone' => 'Europe/Berlin', 'message' => '1st event, CEST: '), + array('index' => 1, 'dateString' => '20191106T190000', 'timezone' => 'Europe/Berlin', 'message' => '2nd event, CEST: '), + array('index' => 2, 'dateString' => '20191107T190000', 'timezone' => 'Europe/Berlin', 'message' => '3rd event, CEST: '), + array('index' => 3, 'dateString' => '20191108T190000', 'timezone' => 'Europe/Berlin', 'message' => '4th event, CEST: '), + array('index' => 4, 'dateString' => '20191109T170000', 'timezone' => 'Europe/Berlin', 'message' => '5th event, CEST: '), + array('index' => 5, 'dateString' => '20191110T180000', 'timezone' => 'Europe/Berlin', 'message' => '6th event, CEST: '), + ); + $this->assertEventFile( + 'UTC', + "./tests/issue196.txt", + 6, + $checks); + } + /** * @runInSeparateProcess */ @@ -226,6 +245,8 @@ function assertEventFile($defaultTimezone, $file, $count, $checks) { $this->assertCount($count, $events); + $events = $ical->sortEventsWithOrder($events); + foreach($checks as $check) { $this->assertEvent($events[$check['index']], $check['dateString'], $check['message'], isset($check['timezone']) ? $check['timezone'] : $defaultTimezone); } diff --git a/tests/issue196.txt b/tests/issue196.txt new file mode 100644 index 0000000..7603969 --- /dev/null +++ b/tests/issue196.txt @@ -0,0 +1,64 @@ +BEGIN:VCALENDAR +PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN +VERSION:2.0 +X-WR-CALNAME:Test-Calendar +X-WR-TIMEZONE:Europe/Berlin +BEGIN:VTIMEZONE +TZID:Europe/Berlin +BEGIN:DAYLIGHT +TZOFFSETFROM:+0100 +TZOFFSETTO:+0200 +TZNAME:CEST +DTSTART:19700329T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:+0200 +TZOFFSETTO:+0100 +TZNAME:CET +DTSTART:19701025T030000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +CREATED:20180101T152047Z +LAST-MODIFIED:20181202T202056Z +DTSTAMP:20181202T202056Z +UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5 +SUMMARY:test +RRULE:FREQ=DAILY;UNTIL=20191111T180000Z +DTSTART;TZID=Europe/Berlin:20191105T190000 +DTEND;TZID=Europe/Berlin:20191105T220000 +TRANSP:OPAQUE +SEQUENCE:24 +X-MOZ-GENERATION:37 +END:VEVENT +BEGIN:VEVENT +CREATED:20181202T202042Z +LAST-MODIFIED:20181202T202053Z +DTSTAMP:20181202T202053Z +UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5 +SUMMARY:test +RECURRENCE-ID;TZID=Europe/Berlin:20191109T190000 +DTSTART;TZID=Europe/Berlin:20191109T170000 +DTEND;TZID=Europe/Berlin:20191109T220000 +TRANSP:OPAQUE +SEQUENCE:25 +X-MOZ-GENERATION:37 +DURATION:PT0S +END:VEVENT +BEGIN:VEVENT +CREATED:20181202T202053Z +LAST-MODIFIED:20181202T202056Z +DTSTAMP:20181202T202056Z +UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5 +SUMMARY:test +RECURRENCE-ID;TZID=Europe/Berlin:20191110T190000 +DTSTART;TZID=Europe/Berlin:20191110T180000 +DTEND;TZID=Europe/Berlin:20191110T220000 +TRANSP:OPAQUE +SEQUENCE:25 +X-MOZ-GENERATION:37 +DURATION:PT0S +END:VEVENT +END:VCALENDAR From 24a68f49179820a99a79245d717d40b6a029802e Mon Sep 17 00:00:00 2001 From: Matthias Huber Date: Fri, 15 Mar 2019 15:42:35 +0100 Subject: [PATCH 2/3] add unit test for issue 196, reading ics file with exceptions to recurrence rule --- tests/RecurrencesTest.php | 21 +++++++++++++ tests/issue196.txt | 64 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/issue196.txt diff --git a/tests/RecurrencesTest.php b/tests/RecurrencesTest.php index 773c324..2673206 100644 --- a/tests/RecurrencesTest.php +++ b/tests/RecurrencesTest.php @@ -75,6 +75,25 @@ public function testMonthlyFullDayTimeZoneBerlinFromFile() { $checks); } + /** + * @runInSeparateProcess + */ + public function testIssue196FromFile() { + $checks = array( + array('index' => 0, 'dateString' => '20191105T190000', 'timezone' => 'Europe/Berlin', 'message' => '1st event, CEST: '), + array('index' => 1, 'dateString' => '20191106T190000', 'timezone' => 'Europe/Berlin', 'message' => '2nd event, CEST: '), + array('index' => 2, 'dateString' => '20191107T190000', 'timezone' => 'Europe/Berlin', 'message' => '3rd event, CEST: '), + array('index' => 3, 'dateString' => '20191108T190000', 'timezone' => 'Europe/Berlin', 'message' => '4th event, CEST: '), + array('index' => 4, 'dateString' => '20191109T170000', 'timezone' => 'Europe/Berlin', 'message' => '5th event, CEST: '), + array('index' => 5, 'dateString' => '20191110T180000', 'timezone' => 'Europe/Berlin', 'message' => '6th event, CEST: '), + ); + $this->assertEventFile( + 'UTC', + "./tests/issue196.txt", + 6, + $checks); + } + public function testWeeklyFullDayTimeZoneBerlin() { $checks = array( array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '), @@ -203,6 +222,8 @@ function assertEventFile($defaultTimezone, $file, $count, $checks) { $this->assertCount($count, $events); + $events = $ical->sortEventsWithOrder($events); + foreach($checks as $check) { $this->assertEvent($events[$check['index']], $check['dateString'], $check['message'], isset($check['timezone']) ? $check['timezone'] : $defaultTimezone); } diff --git a/tests/issue196.txt b/tests/issue196.txt new file mode 100644 index 0000000..7603969 --- /dev/null +++ b/tests/issue196.txt @@ -0,0 +1,64 @@ +BEGIN:VCALENDAR +PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN +VERSION:2.0 +X-WR-CALNAME:Test-Calendar +X-WR-TIMEZONE:Europe/Berlin +BEGIN:VTIMEZONE +TZID:Europe/Berlin +BEGIN:DAYLIGHT +TZOFFSETFROM:+0100 +TZOFFSETTO:+0200 +TZNAME:CEST +DTSTART:19700329T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:+0200 +TZOFFSETTO:+0100 +TZNAME:CET +DTSTART:19701025T030000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +CREATED:20180101T152047Z +LAST-MODIFIED:20181202T202056Z +DTSTAMP:20181202T202056Z +UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5 +SUMMARY:test +RRULE:FREQ=DAILY;UNTIL=20191111T180000Z +DTSTART;TZID=Europe/Berlin:20191105T190000 +DTEND;TZID=Europe/Berlin:20191105T220000 +TRANSP:OPAQUE +SEQUENCE:24 +X-MOZ-GENERATION:37 +END:VEVENT +BEGIN:VEVENT +CREATED:20181202T202042Z +LAST-MODIFIED:20181202T202053Z +DTSTAMP:20181202T202053Z +UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5 +SUMMARY:test +RECURRENCE-ID;TZID=Europe/Berlin:20191109T190000 +DTSTART;TZID=Europe/Berlin:20191109T170000 +DTEND;TZID=Europe/Berlin:20191109T220000 +TRANSP:OPAQUE +SEQUENCE:25 +X-MOZ-GENERATION:37 +DURATION:PT0S +END:VEVENT +BEGIN:VEVENT +CREATED:20181202T202053Z +LAST-MODIFIED:20181202T202056Z +DTSTAMP:20181202T202056Z +UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5 +SUMMARY:test +RECURRENCE-ID;TZID=Europe/Berlin:20191110T190000 +DTSTART;TZID=Europe/Berlin:20191110T180000 +DTEND;TZID=Europe/Berlin:20191110T220000 +TRANSP:OPAQUE +SEQUENCE:25 +X-MOZ-GENERATION:37 +DURATION:PT0S +END:VEVENT +END:VCALENDAR From 04daa6eba48fecacaacbe36fbb404c975157cb24 Mon Sep 17 00:00:00 2001 From: Matthias Huber Date: Mon, 25 Mar 2019 21:05:14 +0100 Subject: [PATCH 3/3] some cosmetics, remove @runInSeparateProcess --- tests/RecurrencesTest.php | 5 +---- tests/{issue196.txt => ical/issue-196.ics} | 0 2 files changed, 1 insertion(+), 4 deletions(-) rename tests/{issue196.txt => ical/issue-196.ics} (100%) diff --git a/tests/RecurrencesTest.php b/tests/RecurrencesTest.php index 2673206..b0bc9c7 100644 --- a/tests/RecurrencesTest.php +++ b/tests/RecurrencesTest.php @@ -75,9 +75,6 @@ public function testMonthlyFullDayTimeZoneBerlinFromFile() { $checks); } - /** - * @runInSeparateProcess - */ public function testIssue196FromFile() { $checks = array( array('index' => 0, 'dateString' => '20191105T190000', 'timezone' => 'Europe/Berlin', 'message' => '1st event, CEST: '), @@ -89,7 +86,7 @@ public function testIssue196FromFile() { ); $this->assertEventFile( 'UTC', - "./tests/issue196.txt", + "./tests/ical/issue-196.ics", 6, $checks); } diff --git a/tests/issue196.txt b/tests/ical/issue-196.ics similarity index 100% rename from tests/issue196.txt rename to tests/ical/issue-196.ics