Skip to content

Commit

Permalink
fixup! fix(caldav): event search with limit and timerange
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed May 8, 2024
1 parent ab8f6cf commit f5cd3f0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1655,4 +1655,54 @@ public function testSearchWithLimitAndTimeRange() {
'Recurrence starting before requested start',
);
}

public function testSearchWithLimitAndTimeRangeShouldNotReturnMoreObjectsThenLimit() {
$calendarId = $this->createTestCalendar();
$calendarInfo = [
'id' => $calendarId,
'principaluri' => 'user1',
'{http://owncloud.org/ns}owner-principal' => 'user1',
];

$testFiles = [
__DIR__ . '/../../misc/caldav-search-limit-timerange-1.ics',
__DIR__ . '/../../misc/caldav-search-limit-timerange-2.ics',
__DIR__ . '/../../misc/caldav-search-limit-timerange-3.ics',
__DIR__ . '/../../misc/caldav-search-limit-timerange-4.ics',
__DIR__ . '/../../misc/caldav-search-limit-timerange-5.ics',
__DIR__ . '/../../misc/caldav-search-limit-timerange-6.ics',
];

foreach ($testFiles as $testFile) {
$objectUri = static::getUniqueID('search-limit-timerange-');
$calendarData = \file_get_contents($testFile);
$this->backend->createCalendarObject($calendarId, $objectUri, $calendarData);
}

$start = new DateTimeImmutable('2024-05-06T00:00:00Z');
$end = $start->add(new DateInterval('P14D'));

$results = $this->backend->search(
$calendarInfo,
'',
[],
[
'timerange' => [
'start' => $start,
'end' => $end,
]
],
1,
null,
);

$this->assertCount(1, $results);

$this->assertEquals('Cake Tasting', $results[0]['objects'][0]['SUMMARY'][0]);
$this->assertGreaterThanOrEqual(
$start->getTimestamp(),
$results[0]['objects'][0]['DTSTART'][0]->getTimestamp(),
'Recurrence starting before requested start',
);
}
}

0 comments on commit f5cd3f0

Please sign in to comment.