Skip to content

Commit

Permalink
Add unit test cases for variations of specifying time-range
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jan 11, 2021
1 parent 282b8cd commit ef7d410
Showing 1 changed file with 89 additions and 1 deletion.
90 changes: 89 additions & 1 deletion tests/Sabre/CalDAV/Backend/AbstractPDOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ public function testCalendarQueryTimeRange()
], $backend->calendarQuery([1, 1], $filters));
}

public function testCalendarQueryTimeRangeNoEnd()
public function testCalendarQueryTimeRangeEndNull()
{
$backend = new PDO($this->pdo);
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
Expand Down Expand Up @@ -811,6 +811,94 @@ public function testCalendarQueryTimeRangeNoEnd()
], $backend->calendarQuery([1, 1], $filters));
}

public function testCalendarQueryTimeRangeNoEnd()
{
$backend = new PDO($this->pdo);
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
$backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
$backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");

$filters = [
'name' => 'VCALENDAR',
'comp-filters' => [
[
'name' => 'VEVENT',
'comp-filters' => [],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => [
'start' => new \DateTime('20120102'),
],
],
],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => null,
];

$this->assertEquals([
'event2',
], $backend->calendarQuery([1, 1], $filters));
}

public function testCalendarQueryTimeRangeNoStart()
{
$backend = new PDO($this->pdo);
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
$backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
$backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");

$filters = [
'name' => 'VCALENDAR',
'comp-filters' => [
[
'name' => 'VEVENT',
'comp-filters' => [],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => [
'end' => new \DateTime('20120102'),
],
],
],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => null,
];

$this->assertEquals([
'event',
], $backend->calendarQuery([1, 1], $filters));
}

public function testCalendarQueryTimeRangeNotSpecified()
{
$backend = new PDO($this->pdo);
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
$backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
$backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");

$filters = [
'name' => 'VCALENDAR',
'comp-filters' => [
[
'name' => 'VEVENT',
'comp-filters' => [],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => false,
],
],
'prop-filters' => [],
'is-not-defined' => false,
'time-range' => null,
];

$result = $backend->calendarQuery([1, 1], $filters);
$this->assertTrue(in_array('event', $result));
$this->assertTrue(in_array('event2', $result));
}

public function testGetChanges()
{
$backend = new PDO($this->pdo);
Expand Down

0 comments on commit ef7d410

Please sign in to comment.