Skip to content

Commit 8aed988

Browse files
committed
Add unit test cases for variations of specifying time-range
1 parent b20b175 commit 8aed988

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

tests/Sabre/CalDAV/Backend/AbstractPDOTest.php

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ public function testCalendarQueryTimeRange()
780780
], $backend->calendarQuery([1, 1], $filters));
781781
}
782782

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

814+
public function testCalendarQueryTimeRangeNoEnd()
815+
{
816+
$backend = new PDO($this->pdo);
817+
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
818+
$backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
819+
$backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
820+
821+
$filters = [
822+
'name' => 'VCALENDAR',
823+
'comp-filters' => [
824+
[
825+
'name' => 'VEVENT',
826+
'comp-filters' => [],
827+
'prop-filters' => [],
828+
'is-not-defined' => false,
829+
'time-range' => [
830+
'start' => new \DateTime('20120102'),
831+
],
832+
],
833+
],
834+
'prop-filters' => [],
835+
'is-not-defined' => false,
836+
'time-range' => null,
837+
];
838+
839+
$this->assertEquals([
840+
'event2',
841+
], $backend->calendarQuery([1, 1], $filters));
842+
}
843+
844+
public function testCalendarQueryTimeRangeNoStart()
845+
{
846+
$backend = new PDO($this->pdo);
847+
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
848+
$backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
849+
$backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
850+
851+
$filters = [
852+
'name' => 'VCALENDAR',
853+
'comp-filters' => [
854+
[
855+
'name' => 'VEVENT',
856+
'comp-filters' => [],
857+
'prop-filters' => [],
858+
'is-not-defined' => false,
859+
'time-range' => [
860+
'end' => new \DateTime('20120102'),
861+
],
862+
],
863+
],
864+
'prop-filters' => [],
865+
'is-not-defined' => false,
866+
'time-range' => null,
867+
];
868+
869+
$this->assertEquals([
870+
'event',
871+
], $backend->calendarQuery([1, 1], $filters));
872+
}
873+
874+
public function testCalendarQueryTimeRangeNotSpecified()
875+
{
876+
$backend = new PDO($this->pdo);
877+
$backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
878+
$backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
879+
$backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
880+
881+
$filters = [
882+
'name' => 'VCALENDAR',
883+
'comp-filters' => [
884+
[
885+
'name' => 'VEVENT',
886+
'comp-filters' => [],
887+
'prop-filters' => [],
888+
'is-not-defined' => false,
889+
'time-range' => false,
890+
],
891+
],
892+
'prop-filters' => [],
893+
'is-not-defined' => false,
894+
'time-range' => null,
895+
];
896+
897+
$result = $backend->calendarQuery([1, 1], $filters);
898+
$this->assertTrue(in_array('event', $result));
899+
$this->assertTrue(in_array('event2', $result));
900+
}
901+
814902
public function testGetChanges()
815903
{
816904
$backend = new PDO($this->pdo);

0 commit comments

Comments
 (0)