Skip to content

Commit

Permalink
Add unit test for bug #15054
Browse files Browse the repository at this point in the history
  • Loading branch information
ralflang authored and mrubinsk committed Mar 24, 2022
1 parent 6991974 commit 727a744
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/Horde/Date/RecurrenceTest.php
Expand Up @@ -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());
}
}
27 changes: 27 additions & 0 deletions 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

0 comments on commit 727a744

Please sign in to comment.