From 727a74493cad3bfb5f5724020df96e76b19a0cdf Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Thu, 17 Mar 2022 09:10:56 +0000 Subject: [PATCH] Add unit test for bug #15054 --- test/Horde/Date/RecurrenceTest.php | 43 +++++++++++++++++++++++++++ test/Horde/Date/fixtures/bug15054.ics | 27 +++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 test/Horde/Date/fixtures/bug15054.ics diff --git a/test/Horde/Date/RecurrenceTest.php b/test/Horde/Date/RecurrenceTest.php index a5c0ab3..bb63ac6 100644 --- a/test/Horde/Date/RecurrenceTest.php +++ b/test/Horde/Date/RecurrenceTest.php @@ -1094,4 +1094,47 @@ public function testBug12869RecurrenceEndFromIcalendar() date_default_timezone_set('Europe/Berlin'); } + public function testBug15054ThunderbirdWorkday() + { + date_default_timezone_set('Europe/Berlin'); + $iCal = new Horde_Icalendar(); + $iCal->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug15054.ics')); + $components = $iCal->getComponents(); + foreach ($components as $content) { + if ($content instanceof Horde_Icalendar_Vevent) { + $start = new Horde_Date($content->getAttribute('DTSTART')); + $end = new Horde_Date($content->getAttribute('DTEND')); + $rrule = $content->getAttribute('RRULE'); + $recurrence = new Horde_Date_Recurrence($start, $end); + $recurrence->fromRRule20($rrule); + break; + } + } + + // Recurrence must not include weekend + // Thursday, checking for thursday + $dtInput = new \Horde_Date('20210318T080000', 'Europe/Berlin'); + $dtExpected = new \Horde_Date('20210318T090000', 'Europe/Berlin'); + $this->assertEquals($dtExpected->timestamp(), $recurrence->nextRecurrence($dtInput)->timestamp()); + // Friday, checking for friday + $dtInput = new \Horde_Date('20210319T080000', 'Europe/Berlin'); + $dtExpected = new \Horde_Date('20210319T090000', 'Europe/Berlin'); + $this->assertEquals($dtExpected->timestamp(), $recurrence->nextRecurrence($dtInput)->timestamp()); + // Saturday, checking for monday + $dtInput = new \Horde_Date('20210320T080000', 'Europe/Berlin'); + $dtExpected = new \Horde_Date('20210322T090000', 'Europe/Berlin'); + $this->assertEquals($dtExpected->toJSON(), $recurrence->nextRecurrence($dtInput)->toJSON()); + // Sunday, checking for monday + $dtInput = new \Horde_Date('20210321T080000', 'Europe/Berlin'); + $dtExpected = new \Horde_Date('20210322T090000', 'Europe/Berlin'); + $this->assertEquals($dtExpected->timestamp(), $recurrence->nextRecurrence($dtInput)->timestamp()); + // monday, checking for monday + $dtInput = new \Horde_Date('20210322T080000', 'Europe/Berlin'); + $dtExpected = new \Horde_Date('20210322T090000', 'Europe/Berlin'); + $this->assertEquals($dtExpected->timestamp(), $recurrence->nextRecurrence($dtInput)->timestamp()); + // tuesday, checking for tuesday + $dtInput = new \Horde_Date('20210323T080000', 'Europe/Berlin'); + $dtExpected = new \Horde_Date('20210323T090000', 'Europe/Berlin'); + $this->assertEquals($dtExpected->timestamp(), $recurrence->nextRecurrence($dtInput)->timestamp()); + } } diff --git a/test/Horde/Date/fixtures/bug15054.ics b/test/Horde/Date/fixtures/bug15054.ics new file mode 100644 index 0000000..6ec0c71 --- /dev/null +++ b/test/Horde/Date/fixtures/bug15054.ics @@ -0,0 +1,27 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:Bug Reproducer +PRODID:-//The Horde Project//Horde iCalendar Library//EN +BEGIN:VEVENT +DTSTART;TZID=Europe/Berlin:20210318T090000 +DTEND;TZID=Europe/Berlin:20210318T100000 +DTSTAMP:20210318T072609Z +UID:1bae8052-9389-4059-b693-52f6138d5107 +CREATED:20210318T072313Z +LAST-MODIFIED:20210318T072313Z +SUMMARY:Bug 15054 +DESCRIPTION:Thunderbird creates a new event as "Jeden Werktag" (recurring + all work days). \nThis is expressed as a DAILY clause with an BYDAY + attribute listing the five workdays.\nHorde before this patch would only + parse BYDAY from weeks. The server accepts the meeting but drops the + restriction. The Event will be saved as "all days" and on next sync\, + the TB user has an "all days" event rather than an "all work days" + event. +LOCATION:https://bugs.horde.org/ticket/15054 +CLASS:PUBLIC +STATUS:CONFIRMED +TRANSP:OPAQUE +RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20210331T215959Z;BYDAY=MO,TU,WE,TH,FR +END:VEVENT +END:VCALENDAR +