fix foreach error for reminder generator

Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
Georg Ehrke 2019-08-18 20:56:57 +02:00
parent 08a61f3373
commit 6f66fba559
No known key found for this signature in database
GPG key ID: 9D98FD9380A1CB43
2 changed files with 40 additions and 0 deletions

View file

@ -196,6 +196,10 @@ class ReminderService {
foreach($recurrenceExceptions as $recurrenceException) {
$eventHash = $this->getEventHash($recurrenceException);
if (!isset($recurrenceException->VALARM)) {
continue;
}
foreach($recurrenceException->VALARM as $valarm) {
/** @var VAlarm $valarm */
$alarmHash = $this->getAlarmHash($valarm);
@ -216,6 +220,10 @@ class ReminderService {
$masterAlarms = [];
$masterHash = $this->getEventHash($masterItem);
if (!isset($masterItem->VALARM)) {
return;
}
foreach($masterItem->VALARM as $valarm) {
$masterAlarms[] = $this->getAlarmHash($valarm);
}

View file

@ -164,6 +164,23 @@ TRIGGER:-P8D
END:VALARM
END:VEVENT
END:VCALENDAR
EOD;
public const CALENDAR_DATA_NO_ALARM = <<<EOD
BEGIN:VCALENDAR
PRODID:-//Nextcloud calendar v1.6.4
BEGIN:VEVENT
CREATED:20160602T133732
DTSTAMP:20160602T133732
LAST-MODIFIED:20160602T133732
UID:wej2z68l9h
SUMMARY:Test Event
LOCATION:Somewhere ...
DESCRIPTION:maybe ....
DTSTART;TZID=Europe/Berlin;VALUE=DATE:20160609
DTEND;TZID=Europe/Berlin;VALUE=DATE:20160610
END:VEVENT
END:VCALENDAR
EOD;
public function setUp() {
@ -278,6 +295,21 @@ EOD;
$this->reminderService->onTouchCalendarObject($action, $objectData);
}
public function testOnCalendarObjectCreateEmpty():void {
$action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject';
$objectData = [
'calendardata' => self::CALENDAR_DATA_NO_ALARM,
'id' => '42',
'calendarid' => '1337',
'component' => 'vevent',
];
$this->backend->expects($this->never())
->method('insertReminder');
$this->reminderService->onTouchCalendarObject($action, $objectData);
}
public function testOnCalendarObjectCreateRecurringEntryWithRepeat():void {
$action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject';
$objectData = [