Skip to content

Commit 9a4658e

Browse files
committed
Added unit test for overrides with overlapping start times
1 parent e4b28c3 commit 9a4658e

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

test/unit/CalendarTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,63 @@ public function test_recurrences_with_overrides() {
350350
], $starts);
351351
}
352352

353+
public function test_recurrences_with_duplicate_start_time_overrides() {
354+
// single event series:
355+
// - 3/1 - 3/7 M/W/F 10am - 3pm, T/Th 11:30am - 3pm, Sat/Sun 11:30am - 4:30pm
356+
$events = [
357+
[
358+
'start' => '2021-03-01 10:00:00',
359+
'end' => '2021-03-01 15:00:00',
360+
'title' => 'Three Times',
361+
'recurrence' => [
362+
'until' => '2021-03-07 15:00:00',
363+
'frequency' => 'Daily',
364+
'exceptions' => [],
365+
'overrides' => [
366+
[
367+
'start' => '10:00:00',
368+
'end' => '15:00:00',
369+
'BYDAY' => ['MO', 'WE', 'FR'],
370+
],
371+
[
372+
'start' => '11:30:00',
373+
'end' => '17:00:00',
374+
'BYDAY' => ['TU', 'TH'],
375+
],
376+
[
377+
'start' => '11:30:00',
378+
'end' => '17:30:00',
379+
'BYDAY' => ['SA', 'SU'],
380+
],
381+
],
382+
],
383+
],
384+
];
385+
386+
$calendar = new Calendar($events);
387+
388+
$starts = array_map(function(array $recurrence) {
389+
return sprintf(
390+
'%s - %s',
391+
$recurrence['start'],
392+
gmdate('H:i:s', strtotime($recurrence['end']))
393+
);
394+
}, $calendar->recurrences([
395+
'earliest' => '2021-03-01',
396+
'latest' => '2021-03-10',
397+
]));
398+
399+
$this->assertEquals([
400+
'2021-03-01 10:00:00 - 15:00:00',
401+
'2021-03-02 11:30:00 - 17:00:00',
402+
'2021-03-03 10:00:00 - 15:00:00',
403+
'2021-03-04 11:30:00 - 17:00:00',
404+
'2021-03-05 10:00:00 - 15:00:00',
405+
'2021-03-06 11:30:00 - 17:30:00',
406+
'2021-03-07 11:30:00 - 17:30:00',
407+
], $starts);
408+
}
409+
353410
public function test_recurrences_with_overrides_weekly() {
354411
// single event series:
355412
// - 3/1 - 3/7 M/W/F 10am - 3pm, Sat/Sun 11:30am - 4:30pm

0 commit comments

Comments
 (0)