diff options
author | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2024-04-17 11:24:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 11:24:12 +0200 |
commit | 8d91e071d7e809753535bd2094927a046e384d51 (patch) | |
tree | 06920c825d4c99cf633d820f54155392d139adb2 /apps/dav/tests | |
parent | 88859aa41cda5140f6c6d55eab58418153c0744c (diff) | |
parent | 823a07bb1d4959e994572c776dca8529e0640d07 (diff) | |
download | nextcloud-server-8d91e071d7e809753535bd2094927a046e384d51.tar.gz nextcloud-server-8d91e071d7e809753535bd2094927a046e384d51.zip |
Merge pull request #44473 from nextcloud/backport/44017/stable28
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php b/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php index efc9ef32afc..836ec46db30 100644 --- a/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); /** * @copyright 2023 Daniel Kesselberg <mail@danielkesselberg.de> + * @copyright 2024 Robert C. Schaller <gtbc_robert.schaller@rsxc.de> * * @author 2023 Daniel Kesselberg <mail@danielkesselberg.de> * @@ -137,4 +138,70 @@ class EventComparisonServiceTest extends TestCase { $this->assertEquals([$vEventOld2], $result['old']); $this->assertEquals([$vEventNew2], $result['new']); } + + // First test to certify fix for issue nextcloud/server#41084 + public function testSequenceNumberIncrementDetectedForFirstModificationToEventWithoutZeroInit(): void { + $vCalendarOld = new VCalendar(); + $vCalendarNew = new VCalendar(); + + $vEventOld = $vCalendarOld->add('VEVENT', [ + 'UID' => 'uid-1234', + 'LAST-MODIFIED' => 123456, + // 'SEQUENCE' => 0, // sequence number may not be set to zero during event creation and instead fully omitted + 'SUMMARY' => 'Fellowship meeting', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00'), + 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z', + ]); + $vEventOld->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $vEventOld->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + + $vEventNew = $vCalendarNew->add('VEVENT', [ + 'UID' => 'uid-1234', + 'LAST-MODIFIED' => 123456, + 'SEQUENCE' => 1, + 'SUMMARY' => 'Fellowship meeting', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00'), + 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z', + ]); + $vEventNew->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $vEventNew->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + + $result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld); + $this->assertEquals([$vEventOld], $result['old']); + $this->assertEquals([$vEventNew], $result['new']); + } + + // Second test to certify fix for issue nextcloud/server#41084 + public function testSequenceNumberIncrementDetectedForFirstModificationToEventWithZeroInit(): void { + $vCalendarOld = new VCalendar(); + $vCalendarNew = new VCalendar(); + + $vEventOld = $vCalendarOld->add('VEVENT', [ + 'UID' => 'uid-1234', + 'LAST-MODIFIED' => 123456, + 'SEQUENCE' => 0, + 'SUMMARY' => 'Fellowship meeting', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00'), + 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z', + ]); + $vEventOld->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $vEventOld->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + + $vEventNew = $vCalendarNew->add('VEVENT', [ + 'UID' => 'uid-1234', + 'LAST-MODIFIED' => 123456, + 'SEQUENCE' => 1, + 'SUMMARY' => 'Fellowship meeting', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00'), + 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z', + ]); + $vEventNew->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $vEventNew->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + + $result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld); + $this->assertEquals([$vEventOld], $result['old']); + $this->assertEquals([$vEventNew], $result['new']); + } + + } |