diff options
author | Sebastian Krupinski <165827823+SebastianKrupinski@users.noreply.github.com> | 2024-08-08 07:55:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 07:55:10 -0400 |
commit | e21fc6c762252e9a87446925c28170261e3027ee (patch) | |
tree | 107feac47267e2675904b5eaa780a872d5e1e424 | |
parent | 2777cf90e333bf57491784812148c6b3db437c85 (diff) | |
parent | 19ec5985b54d61b99c3a68763a97350b0f7afcc2 (diff) | |
download | nextcloud-server-e21fc6c762252e9a87446925c28170261e3027ee.tar.gz nextcloud-server-e21fc6c762252e9a87446925c28170261e3027ee.zip |
Merge pull request #46624 from nextcloud/fix/issue-43923
fix(caldav): test for null and blank value
-rw-r--r-- | apps/dav/lib/CalDAV/Reminder/ReminderService.php | 2 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 6faf5bdecd6..617e71d6d26 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -847,7 +847,7 @@ class ReminderService { private function getCalendarTimeZone(int $calendarid): DateTimeZone { $calendarInfo = $this->caldavBackend->getCalendarById($calendarid); $tzProp = '{urn:ietf:params:xml:ns:caldav}calendar-timezone'; - if (!isset($calendarInfo[$tzProp])) { + if (empty($calendarInfo[$tzProp])) { // Defaulting to UTC return new DateTimeZone('UTC'); } diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index 593131ba5dd..d4594291d88 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -427,7 +427,7 @@ EOD; $this->reminderService->onCalendarObjectCreate($objectData); } - public function testOnCalendarObjectCreateAllDayWithoutTimezone(): void { + public function testOnCalendarObjectCreateAllDayWithNullTimezone(): void { $objectData = [ 'calendardata' => self::CALENDAR_DATA_ALL_DAY, 'id' => '42', @@ -454,6 +454,33 @@ EOD; $this->reminderService->onCalendarObjectCreate($objectData); } + public function testOnCalendarObjectCreateAllDayWithBlankTimezone(): void { + $objectData = [ + 'calendardata' => self::CALENDAR_DATA_ALL_DAY, + 'id' => '42', + 'calendarid' => '1337', + 'component' => 'vevent', + ]; + $this->timeFactory->expects($this->once()) + ->method('getDateTime') + ->with() + ->willReturn(DateTime::createFromFormat(DateTime::ATOM, '2023-02-03T13:28:00+00:00')); + $this->caldavBackend->expects(self::once()) + ->method('getCalendarById') + ->with(1337) + ->willReturn([ + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', + ]); + + // One hour before midnight relative to the server's time + $expectedReminderTimstamp = (new DateTime('2023-02-03T23:00:00'))->getTimestamp(); + $this->backend->expects(self::once()) + ->method('insertReminder') + ->with(1337, 42, self::anything(), false, 1675468800, false, self::anything(), self::anything(), 'EMAIL', true, $expectedReminderTimstamp, false); + + $this->reminderService->onCalendarObjectCreate($objectData); + } + public function testOnCalendarObjectCreateAllDayWithTimezone(): void { $objectData = [ 'calendardata' => self::CALENDAR_DATA_ALL_DAY, |