diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2024-05-15 12:55:40 +0200 |
---|---|---|
committer | Daniel <mail@danielkesselberg.de> | 2024-05-28 19:56:36 +0200 |
commit | b769dc4304862af35946386a235d5e6fdb658ce9 (patch) | |
tree | a04fa7f4cff8117ee0895ada2332c366acd4c9bd /apps/dav/tests/unit | |
parent | 4718a7e4e0c2b738e1076979dbdc08661bd5f305 (diff) | |
download | nextcloud-server-b769dc4304862af35946386a235d5e6fdb658ce9.tar.gz nextcloud-server-b769dc4304862af35946386a235d5e6fdb658ce9.zip |
feat(caldav): order the calendar objects by start date for search
Sorting the events by the start date leads to more predictable results for the search API consumers.
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/CalDavBackendTest.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index f0712ecdc93..94d55336444 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -1737,4 +1737,42 @@ EOD; 'Recurrence starting before requested start', ); } + + public function testSearchShouldReturnObjectsInTheSameOrderMissingDate() { + $calendarId = $this->createTestCalendar(); + $calendarInfo = [ + 'id' => $calendarId, + 'principaluri' => 'user1', + '{http://owncloud.org/ns}owner-principal' => 'user1', + ]; + + $testFiles = [ + __DIR__ . '/../../misc/caldav-search-limit-timerange-6.ics', // <-- intentional! + __DIR__ . '/../../misc/caldav-search-limit-timerange-5.ics', + __DIR__ . '/../../misc/caldav-search-missing-start-1.ics', + __DIR__ . '/../../misc/caldav-search-missing-start-2.ics', + ]; + + foreach ($testFiles as $testFile) { + $objectUri = static::getUniqueID('search-return-objects-in-same-order-'); + $calendarData = \file_get_contents($testFile); + $this->backend->createCalendarObject($calendarId, $objectUri, $calendarData); + } + + $results = $this->backend->search( + $calendarInfo, + '', + [], + [], + 4, + null, + ); + + $this->assertCount(4, $results); + + $this->assertEquals('Cake Tasting', $results[0]['objects'][0]['SUMMARY'][0]); + $this->assertEquals('Pasta Day', $results[1]['objects'][0]['SUMMARY'][0]); + $this->assertEquals('Missing DTSTART 1', $results[2]['objects'][0]['SUMMARY'][0]); + $this->assertEquals('Missing DTSTART 2', $results[3]['objects'][0]['SUMMARY'][0]); + } } |