Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(caldav): test for null and blank value #46624

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ private function isRecurring(VEvent $vevent):bool {
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])) {
Dismissed Show dismissed Hide dismissed
// Defaulting to UTC
return new DateTimeZone('UTC');
}
Expand Down
29 changes: 28 additions & 1 deletion apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public function testOnCalendarObjectCreateEmpty():void {
$this->reminderService->onCalendarObjectCreate($objectData);
}

public function testOnCalendarObjectCreateAllDayWithoutTimezone(): void {
public function testOnCalendarObjectCreateAllDayWithNullTimezone(): void {
$objectData = [
'calendardata' => self::CALENDAR_DATA_ALL_DAY,
'id' => '42',
Expand All @@ -454,6 +454,33 @@ public function testOnCalendarObjectCreateAllDayWithoutTimezone(): void {
$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,
Expand Down
Loading