23 'calendarsubscriptions',
28 $this->pdo = $this->
getDb();
34 $backend =
new PDO($this->pdo);
35 $this->assertTrue($backend instanceof
PDO);
44 $backend =
new PDO($this->pdo);
45 $calendars = $backend->getCalendarsForUser(
'principals/user2');
46 $this->assertEquals([], $calendars);
55 $backend =
new PDO($this->pdo);
56 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', [
57 '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' =>
new CalDAV\Xml\
Property\SupportedCalendarComponentSet([
'VEVENT']),
58 '{DAV:}displayname' =>
'Hello!',
59 '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' =>
new CalDAV\Xml\
Property\ScheduleCalendarTransp(
'transparent'),
61 $calendars = $backend->getCalendarsForUser(
'principals/user2');
64 'uri' =>
'somerandomid',
65 '{DAV:}displayname' =>
'Hello!',
66 '{urn:ietf:params:xml:ns:caldav}calendar-description' =>
'',
71 $this->assertInternalType(
'array', $calendars);
72 $this->assertEquals(1, count($calendars));
74 foreach ($elementCheck as
$name => $value) {
76 $this->assertArrayHasKey(
$name, $calendars[0]);
77 $this->assertEquals($value, $calendars[0][
$name]);
88 $backend =
new PDO($this->pdo);
91 $newId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
94 '{DAV:}displayname' =>
'myCalendar',
95 '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' =>
new CalDAV\Xml\
Property\ScheduleCalendarTransp(
'transparent'),
99 $backend->updateCalendar($newId, $propPatch);
100 $result = $propPatch->commit();
106 $calendars = $backend->getCalendarsForUser(
'principals/user2');
111 'uri' =>
'somerandomid',
112 '{DAV:}displayname' =>
'myCalendar',
113 '{urn:ietf:params:xml:ns:caldav}calendar-description' =>
'',
114 '{urn:ietf:params:xml:ns:caldav}calendar-timezone' =>
'',
115 '{http://calendarserver.org/ns/}getctag' =>
'http://sabre.io/ns/sync/2',
119 $this->assertInternalType(
'array', $calendars);
120 $this->assertEquals(1, count($calendars));
122 foreach ($elementCheck as
$name => $value) {
124 $this->assertArrayHasKey(
$name, $calendars[0]);
125 $this->assertEquals($value, $calendars[0][
$name]);
137 $backend =
new PDO($this->pdo);
140 $newId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
143 '{DAV:}displayname' =>
'myCalendar',
144 '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' =>
new CalDAV\Xml\
Property\ScheduleCalendarTransp(
'transparent'),
148 $backend->updateCalendar(
'raaaa', $propPatch);
157 $backend =
new PDO($this->pdo);
160 $newId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
163 '{DAV:}displayname' =>
'myCalendar',
164 '{DAV:}yourmom' =>
'wittycomment',
168 $backend->updateCalendar($newId, $propPatch);
169 $propPatch->commit();
172 $this->assertEquals([
173 '{DAV:}yourmom' => 403,
174 '{DAV:}displayname' => 424,
175 ], $propPatch->getResult());
184 $backend =
new PDO($this->pdo);
185 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', [
186 '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' =>
new CalDAV\Xml\
Property\SupportedCalendarComponentSet([
'VEVENT']),
187 '{DAV:}displayname' =>
'Hello!',
190 $backend->deleteCalendar($returnedId);
192 $calendars = $backend->getCalendarsForUser(
'principals/user2');
193 $this->assertEquals([], $calendars);
203 $backend =
new PDO($this->pdo);
204 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', [
205 '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' =>
new CalDAV\Xml\
Property\SupportedCalendarComponentSet([
'VEVENT']),
206 '{DAV:}displayname' =>
'Hello!',
209 $backend->deleteCalendar(
'bad-id');
219 $backend =
new PDO($this->pdo);
222 $newId = $backend->createCalendar(
'principals/user2',
'somerandomid', [
223 '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' =>
'blabla',
230 $backend =
new PDO($this->pdo);
231 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
233 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
235 $backend->createCalendarObject($returnedId,
'random-id', $object);
237 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
240 if (is_resource(
$row[
'calendardata'])) {
241 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
244 $this->assertEquals([
245 'etag' => md5($object),
246 'size' => strlen($object),
247 'calendardata' => $object,
248 'firstoccurence' => strtotime(
'20120101'),
249 'lastoccurence' => strtotime(
'20120101') + (3600 * 24),
250 'componenttype' =>
'VEVENT',
256 $backend =
new PDO($this->pdo);
257 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
259 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
261 $backend->createCalendarObject($returnedId,
'id-1', $object);
262 $backend->createCalendarObject($returnedId,
'id-2', $object);
267 'etag' =>
'"' . md5($object) .
'"',
269 'size' => strlen($object),
270 'calendardata' => $object,
271 'lastmodified' => null,
275 'etag' =>
'"' . md5($object) .
'"',
277 'size' => strlen($object),
278 'calendardata' => $object,
279 'lastmodified' => null,
283 $result = $backend->getMultipleCalendarObjects($returnedId, [
'id-1',
'id-2']);
285 foreach ($check as
$index => $props) {
287 foreach ($props as
$key => $expected) {
292 case 'lastmodified' :
293 $this->assertInternalType(
'int', $actual);
295 case 'calendardata' :
296 if (is_resource($actual)) {
297 $actual = stream_get_contents($actual);
301 $this->assertEquals($expected, $actual);
317 $backend =
new PDO($this->pdo);
318 $backend->getMultipleCalendarObjects(
'bad-id', [
'foo-bar']);
328 $backend =
new PDO($this->pdo);
329 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
331 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n";
333 $backend->createCalendarObject($returnedId,
'random-id', $object);
342 $backend =
new PDO($this->pdo);
343 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
345 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
347 $backend->createCalendarObject($returnedId,
'random-id', $object);
349 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
352 if (is_resource(
$row[
'calendardata'])) {
353 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
356 $this->assertEquals([
357 'etag' => md5($object),
358 'size' => strlen($object),
359 'calendardata' => $object,
360 'firstoccurence' => strtotime(
'20120101'),
361 'lastoccurence' => strtotime(
'20120101') + (3600 * 48),
362 'componenttype' =>
'VEVENT',
373 $backend =
new PDO($this->pdo);
374 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
376 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
378 $backend->createCalendarObject(
'bad-id',
'random-id', $object);
388 $backend =
new PDO($this->pdo);
389 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
391 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
393 $backend->createCalendarObject($returnedId,
'random-id', $object);
395 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
397 if (is_resource(
$row[
'calendardata'])) {
398 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
401 $this->assertEquals([
402 'etag' => md5($object),
403 'size' => strlen($object),
404 'calendardata' => $object,
405 'firstoccurence' => strtotime(
'2012-01-01 10:00:00'),
406 'lastoccurence' => strtotime(
'2012-01-01 10:00:00'),
407 'componenttype' =>
'VEVENT',
417 $backend =
new PDO($this->pdo);
418 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
420 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND:20120101T110000Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
422 $backend->createCalendarObject($returnedId,
'random-id', $object);
424 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
426 if (is_resource(
$row[
'calendardata'])) {
427 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
430 $this->assertEquals([
431 'etag' => md5($object),
432 'size' => strlen($object),
433 'calendardata' => $object,
434 'firstoccurence' => strtotime(
'2012-01-01 10:00:00'),
435 'lastoccurence' => strtotime(
'2012-01-01 11:00:00'),
436 'componenttype' =>
'VEVENT',
446 $backend =
new PDO($this->pdo);
447 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
449 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nRRULE:FREQ=DAILY\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
451 $backend->createCalendarObject($returnedId,
'random-id', $object);
453 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
455 if (is_resource(
$row[
'calendardata'])) {
456 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
459 $this->assertEquals([
460 'etag' => md5($object),
461 'size' => strlen($object),
462 'calendardata' => $object,
463 'firstoccurence' => strtotime(
'2012-01-01 10:00:00'),
465 'componenttype' =>
'VEVENT',
475 $backend =
new PDO($this->pdo);
476 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
478 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND;VALUE=DATE-TIME:20120101T110000Z\r\nUID:foo\r\nRRULE:FREQ=DAILY;COUNT=1000\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
480 $backend->createCalendarObject($returnedId,
'random-id', $object);
482 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
484 if (is_resource(
$row[
'calendardata'])) {
485 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
488 $this->assertEquals([
489 'etag' => md5($object),
490 'size' => strlen($object),
491 'calendardata' => $object,
492 'firstoccurence' => strtotime(
'2012-01-01 10:00:00'),
493 'lastoccurence' => strtotime(
'2012-01-01 11:00:00') + (3600 * 24 * 999),
494 'componenttype' =>
'VEVENT',
504 $backend =
new PDO($this->pdo);
505 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
507 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nDUE;VALUE=DATE-TIME:20120101T100000Z\r\nEND:VTODO\r\nEND:VCALENDAR\r\n";
509 $backend->createCalendarObject($returnedId,
'random-id', $object);
511 $result = $this->pdo->query(
'SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\'');
513 if (is_resource(
$row[
'calendardata'])) {
514 $row[
'calendardata'] = stream_get_contents(
$row[
'calendardata']);
517 $this->assertEquals([
518 'etag' => md5($object),
519 'size' => strlen($object),
520 'calendardata' => $object,
521 'firstoccurence' => null,
522 'lastoccurence' => null,
523 'componenttype' =>
'VTODO',
533 $backend =
new PDO($this->pdo);
534 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
536 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
537 $backend->createCalendarObject($returnedId,
'random-id', $object);
539 $data = $backend->getCalendarObjects($returnedId);
541 $this->assertEquals(1, count(
$data));
544 $this->assertEquals(
'random-id',
$data[
'uri']);
545 $this->assertEquals(strlen($object),
$data[
'size']);
555 $backend =
new PDO($this->pdo);
556 $backend->getCalendarObjects(
'bad-id');
566 $backend =
new PDO($this->pdo);
567 $backend->getCalendarObject(
'bad-id',
'foo-bar');
576 $backend =
new PDO($this->pdo);
577 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
579 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
580 $backend->createCalendarObject($returnedId,
'random-id', $object);
583 $backend->getCalendarObjectByUID(
'principals/user2',
'bar')
586 'somerandomid/random-id',
587 $backend->getCalendarObjectByUID(
'principals/user2',
'foo')
597 $backend =
new PDO($this->pdo);
598 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
600 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
601 $object2 =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20130101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
602 $backend->createCalendarObject($returnedId,
'random-id', $object);
603 $backend->updateCalendarObject($returnedId,
'random-id', $object2);
605 $data = $backend->getCalendarObject($returnedId,
'random-id');
607 if (is_resource(
$data[
'calendardata'])) {
608 $data[
'calendardata'] = stream_get_contents(
$data[
'calendardata']);
611 $this->assertEquals($object2,
$data[
'calendardata']);
612 $this->assertEquals(
'random-id',
$data[
'uri']);
623 $backend =
new PDO($this->pdo);
624 $backend->updateCalendarObject(
'bad-id',
'object-id',
'objectdata');
633 $backend =
new PDO($this->pdo);
634 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
636 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
637 $backend->createCalendarObject($returnedId,
'random-id', $object);
638 $backend->deleteCalendarObject($returnedId,
'random-id');
640 $data = $backend->getCalendarObject($returnedId,
'random-id');
641 $this->assertNull(
$data);
651 $backend =
new PDO($this->pdo);
652 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
654 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
655 $backend->createCalendarObject($returnedId,
'random-id', $object);
656 $backend->deleteCalendarObject(
'bad-id',
'random-id');
662 $abstract =
new PDO($this->pdo);
664 'name' =>
'VCALENDAR',
667 'name' =>
'VJOURNAL',
668 'comp-filters' => [],
669 'prop-filters' => [],
670 'is-not-defined' =>
false,
671 'time-range' => null,
674 'prop-filters' => [],
675 'is-not-defined' =>
false,
676 'time-range' => null,
679 $this->assertEquals([
680 ], $abstract->calendarQuery([1, 1], $filters));
690 $abstract =
new PDO($this->pdo);
692 'name' =>
'VCALENDAR',
695 'name' =>
'VJOURNAL',
696 'comp-filters' => [],
697 'prop-filters' => [],
698 'is-not-defined' =>
false,
699 'time-range' => null,
702 'prop-filters' => [],
703 'is-not-defined' =>
false,
704 'time-range' => null,
707 $abstract->calendarQuery(
'bad-id', $filters);
713 $backend =
new PDO($this->pdo);
714 $backend->createCalendarObject([1, 1],
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
715 $backend->createCalendarObject([1, 1],
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
718 'name' =>
'VCALENDAR',
722 'comp-filters' => [],
723 'prop-filters' => [],
724 'is-not-defined' =>
false,
725 'time-range' => null,
728 'prop-filters' => [],
729 'is-not-defined' =>
false,
730 'time-range' => null,
733 $this->assertEquals([
735 ], $backend->calendarQuery([1, 1], $filters));
740 $backend =
new PDO($this->pdo);
741 $backend->createCalendarObject([1, 1],
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
742 $backend->createCalendarObject([1, 1],
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
745 'name' =>
'VCALENDAR',
749 'comp-filters' => [],
753 'text-match' => null,
754 'time-range' => null,
755 'param-filters' => [],
756 'is-not-defined' =>
false,
759 'is-not-defined' =>
false,
760 'time-range' => null,
763 'prop-filters' => [],
764 'is-not-defined' =>
false,
765 'time-range' => null,
768 $this->assertEquals([
769 ], $backend->calendarQuery([1, 1], $filters));
775 $backend =
new PDO($this->pdo);
776 $backend->createCalendarObject([1, 1],
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
777 $backend->createCalendarObject([1, 1],
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
780 'name' =>
'VCALENDAR',
781 'comp-filters' => [],
782 'prop-filters' => [],
783 'is-not-defined' =>
false,
784 'time-range' => null,
787 $result = $backend->calendarQuery([1, 1], $filters);
788 $this->assertTrue(in_array(
'todo',
$result));
789 $this->assertTrue(in_array(
'event',
$result));
795 $backend =
new PDO($this->pdo);
796 $backend->createCalendarObject([1, 1],
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
797 $backend->createCalendarObject([1, 1],
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
798 $backend->createCalendarObject([1, 1],
"event2",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
801 'name' =>
'VCALENDAR',
805 'comp-filters' => [],
806 'prop-filters' => [],
807 'is-not-defined' =>
false,
809 'start' => new \DateTime(
'20120103'),
810 'end' => new \DateTime(
'20120104'),
814 'prop-filters' => [],
815 'is-not-defined' =>
false,
816 'time-range' => null,
819 $this->assertEquals([
821 ], $backend->calendarQuery([1, 1], $filters));
826 $backend =
new PDO($this->pdo);
827 $backend->createCalendarObject([1, 1],
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
828 $backend->createCalendarObject([1, 1],
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
829 $backend->createCalendarObject([1, 1],
"event2",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
832 'name' =>
'VCALENDAR',
836 'comp-filters' => [],
837 'prop-filters' => [],
838 'is-not-defined' =>
false,
840 'start' => new \DateTime(
'20120102'),
845 'prop-filters' => [],
846 'is-not-defined' =>
false,
847 'time-range' => null,
850 $this->assertEquals([
852 ], $backend->calendarQuery([1, 1], $filters));
858 $backend =
new PDO($this->pdo);
859 $id = $backend->createCalendar(
864 $result = $backend->getChangesForCalendar(
$id, null, 1);
866 $this->assertEquals([
873 $currentToken =
$result[
'syncToken'];
875 $dummyTodo =
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n";
877 $backend->createCalendarObject(
$id,
"todo1.ics", $dummyTodo);
878 $backend->createCalendarObject(
$id,
"todo2.ics", $dummyTodo);
879 $backend->createCalendarObject(
$id,
"todo3.ics", $dummyTodo);
880 $backend->updateCalendarObject(
$id,
"todo1.ics", $dummyTodo);
881 $backend->deleteCalendarObject(
$id,
"todo2.ics");
883 $result = $backend->getChangesForCalendar(
$id, $currentToken, 1);
885 $this->assertEquals([
887 'modified' => [
"todo1.ics"],
888 'deleted' => [
"todo2.ics"],
889 'added' => [
"todo3.ics"],
892 $result = $backend->getChangesForCalendar(
$id, null, 1);
894 $this->assertEquals([
898 'added' => [
"todo1.ics",
"todo3.ics"],
908 $backend =
new PDO($this->pdo);
909 $id = $backend->createCalendar(
914 $backend->getChangesForCalendar(
'bad-id', null, 1);
921 '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href(
'http://example.org/cal.ics',
false),
922 '{DAV:}displayname' =>
'cal',
923 '{http://apple.com/ns/ical/}refreshrate' =>
'P1W',
924 '{http://apple.com/ns/ical/}calendar-color' =>
'#FF00FFFF',
925 '{http://calendarserver.org/ns/}subscribed-strip-todos' =>
true,
927 '{http://calendarserver.org/ns/}subscribed-strip-attachments' =>
true,
930 $backend =
new PDO($this->pdo);
931 $backend->createSubscription(
'principals/user1',
'sub1', $props);
933 $subs = $backend->getSubscriptionsForUser(
'principals/user1');
937 $expected[
'uri'] =
'sub1';
938 $expected[
'principaluri'] =
'principals/user1';
940 unset($expected[
'{http://calendarserver.org/ns/}source']);
941 $expected[
'source'] =
'http://example.org/cal.ics';
943 $this->assertEquals(1, count($subs));
944 foreach ($expected as $k => $v) {
945 $this->assertEquals($subs[0][$k], $expected[$k]);
958 $backend =
new PDO($this->pdo);
959 $backend->createSubscription(
'principals/user1',
'sub1', $props);
966 '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href(
'http://example.org/cal.ics',
false),
967 '{DAV:}displayname' =>
'cal',
968 '{http://apple.com/ns/ical/}refreshrate' =>
'P1W',
969 '{http://apple.com/ns/ical/}calendar-color' =>
'#FF00FFFF',
970 '{http://calendarserver.org/ns/}subscribed-strip-todos' =>
true,
972 '{http://calendarserver.org/ns/}subscribed-strip-attachments' =>
true,
975 $backend =
new PDO($this->pdo);
976 $backend->createSubscription(
'principals/user1',
'sub1', $props);
979 '{DAV:}displayname' =>
'new displayname',
980 '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href(
'http://example.org/cal2.ics',
false),
984 $backend->updateSubscription(1, $propPatch);
985 $result = $propPatch->commit();
989 $subs = $backend->getSubscriptionsForUser(
'principals/user1');
991 $expected = array_merge($props, $newProps);
993 $expected[
'uri'] =
'sub1';
994 $expected[
'principaluri'] =
'principals/user1';
996 unset($expected[
'{http://calendarserver.org/ns/}source']);
997 $expected[
'source'] =
'http://example.org/cal2.ics';
999 $this->assertEquals(1, count($subs));
1000 foreach ($expected as $k => $v) {
1001 $this->assertEquals($subs[0][$k], $expected[$k]);
1009 '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href(
'http://example.org/cal.ics',
false),
1010 '{DAV:}displayname' =>
'cal',
1011 '{http://apple.com/ns/ical/}refreshrate' =>
'P1W',
1012 '{http://apple.com/ns/ical/}calendar-color' =>
'#FF00FFFF',
1013 '{http://calendarserver.org/ns/}subscribed-strip-todos' =>
true,
1015 '{http://calendarserver.org/ns/}subscribed-strip-attachments' =>
true,
1018 $backend =
new PDO($this->pdo);
1019 $backend->createSubscription(
'principals/user1',
'sub1', $props);
1022 '{DAV:}displayname' =>
'new displayname',
1023 '{http://calendarserver.org/ns/}source' =>
new \
Sabre\DAV\Xml\
Property\
Href(
'http://example.org/cal2.ics',
false),
1024 '{DAV:}unknown' =>
'foo',
1027 $backend->updateSubscription(1, $propPatch);
1028 $propPatch->commit();
1030 $this->assertEquals([
1031 '{DAV:}unknown' => 403,
1032 '{DAV:}displayname' => 424,
1033 '{http://calendarserver.org/ns/}source' => 424,
1034 ], $propPatch->getResult());
1041 '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href(
'http://example.org/cal.ics',
false),
1042 '{DAV:}displayname' =>
'cal',
1043 '{http://apple.com/ns/ical/}refreshrate' =>
'P1W',
1044 '{http://apple.com/ns/ical/}calendar-color' =>
'#FF00FFFF',
1045 '{http://calendarserver.org/ns/}subscribed-strip-todos' =>
true,
1047 '{http://calendarserver.org/ns/}subscribed-strip-attachments' =>
true,
1050 $backend =
new PDO($this->pdo);
1051 $backend->createSubscription(
'principals/user1',
'sub1', $props);
1054 '{DAV:}displayname' =>
'new displayname',
1055 '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href(
'http://example.org/cal2.ics',
false),
1058 $backend->deleteSubscription(1);
1060 $subs = $backend->getSubscriptionsForUser(
'principals/user1');
1061 $this->assertEquals(0, count($subs));
1066 $backend =
new PDO($this->pdo);
1068 $calData =
"BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n";
1070 $backend->createSchedulingObject(
1077 'calendardata' => $calData,
1078 'uri' =>
'schedule1.ics',
1079 'etag' =>
'"' . md5($calData) .
'"',
1080 'size' => strlen($calData)
1083 $result = $backend->getSchedulingObject(
'principals/user1',
'schedule1.ics');
1084 foreach ($expected as $k => $v) {
1085 $this->assertArrayHasKey($k,
$result);
1086 if (is_resource(
$result[$k])) {
1089 $this->assertEquals($v,
$result[$k]);
1092 $results = $backend->getSchedulingObjects(
'principals/user1');
1094 $this->assertEquals(1, count(
$results));
1096 foreach ($expected as $k => $v) {
1097 if (is_resource(
$result[$k])) {
1100 $this->assertEquals($v,
$result[$k]);
1103 $backend->deleteSchedulingObject(
'principals/user1',
'schedule1.ics');
1104 $result = $backend->getSchedulingObject(
'principals/user1',
'schedule1.ics');
1112 $backend =
new PDO($this->pdo);
1115 $backend->createCalendar(
'principals/user1',
'somerandomid', []);
1116 $calendar = $backend->getCalendarsForUser(
'principals/user1')[0];
1121 'href' =>
'principals/user1',
1122 'principal' =>
'principals/user1',
1123 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER,
1124 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1128 $this->assertEquals($expected,
$result);
1138 $backend =
new PDO($this->pdo);
1141 $backend->createCalendar(
'principals/user1',
'somerandomid', []);
1142 $calendar = $backend->getCalendarsForUser(
'principals/user1')[0];
1144 $backend->getInvites(
'bad-id');
1153 $backend =
new PDO($this->pdo);
1156 $backend->createCalendar(
'principals/user1',
'somerandomid', []);
1157 $calendar = $backend->getCalendarsForUser(
'principals/user1')[0];
1159 $ownerSharee =
new Sharee([
1160 'href' =>
'principals/user1',
1161 'principal' =>
'principals/user1',
1162 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER,
1163 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1167 $backend->updateInvites(
1171 'href' =>
'mailto:user@example.org',
1172 'principal' =>
'principals/user2',
1173 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READ,
1174 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1175 'properties' => [
'{DAV:}displayname' =>
'User 2'],
1184 'href' =>
'mailto:user@example.org',
1185 'principal' =>
'principals/user2',
1186 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READ,
1187 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1189 '{DAV:}displayname' =>
'User 2',
1193 $this->assertEquals($expected,
$result);
1196 $expectedCalendar = [
1198 'principaluri' =>
'principals/user2',
1199 '{http://calendarserver.org/ns/}getctag' =>
'http://sabre.io/ns/sync/1',
1200 '{http://sabredav.org/ns}sync-token' =>
'1',
1202 'read-only' =>
true,
1203 'share-resource-uri' =>
'/ns/share/1',
1205 $calendars = $backend->getCalendarsForUser(
'principals/user2');
1207 foreach ($expectedCalendar as $k => $v) {
1208 $this->assertEquals(
1211 "Key " . $k .
" in calendars array did not have the expected value." 1217 $backend->updateInvites(
1221 'href' =>
'mailto:user@example.org',
1222 'principal' =>
'principals/user2',
1223 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
1224 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1233 'href' =>
'mailto:user@example.org',
1234 'principal' =>
'principals/user2',
1235 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
1236 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1238 '{DAV:}displayname' =>
'User 2',
1242 $this->assertEquals($expected,
$result);
1245 $backend->updateInvites(
1249 'href' =>
'mailto:user@example.org',
1250 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS,
1259 $this->assertEquals($expected,
$result);
1262 $backend->updateInvites(
1266 'href' =>
'principals/user2',
1267 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS,
1275 'href' =>
'principals/user1',
1276 'principal' =>
'principals/user1',
1277 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER,
1278 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1281 $this->assertEquals($expected,
$result);
1291 $backend =
new PDO($this->pdo);
1293 $backend->updateInvites(
1305 $backend =
new PDO($this->pdo);
1308 $backend->createCalendar(
'principals/user1',
'somerandomid', []);
1309 $calendar = $backend->getCalendarsForUser(
'principals/user1')[0];
1311 $ownerSharee =
new Sharee([
1312 'href' =>
'principals/user1',
1313 'principal' =>
'principals/user1',
1314 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER,
1315 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1319 $backend->updateInvites(
1323 'href' =>
'mailto:user@example.org',
1324 'principal' => null,
1325 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READ,
1326 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1327 'properties' => [
'{DAV:}displayname' =>
'User 2'],
1336 'href' =>
'mailto:user@example.org',
1337 'principal' => null,
1338 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READ,
1339 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_INVALID,
1341 '{DAV:}displayname' =>
'User 2',
1345 $this->assertEquals($expected,
$result, null, 0.0, 10,
true);
1354 $backend =
new PDO($this->pdo);
1357 $backend->createCalendar(
'principals/user1',
'somerandomid', []);
1358 $calendar = $backend->getCalendarsForUser(
'principals/user1')[0];
1360 $ownerSharee =
new Sharee([
1361 'href' =>
'principals/user1',
1362 'principal' =>
'principals/user1',
1363 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER,
1364 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1368 $backend->updateInvites(
1372 'href' =>
'mailto:user@example.org',
1373 'principal' =>
'principals/user2',
1374 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_READ,
1375 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1376 'properties' => [
'{DAV:}displayname' =>
'User 2'],
1381 $expectedCalendar = [
1383 'principaluri' =>
'principals/user2',
1384 '{http://calendarserver.org/ns/}getctag' =>
'http://sabre.io/ns/sync/1',
1385 '{http://sabredav.org/ns}sync-token' =>
'1',
1387 'read-only' =>
true,
1388 'share-resource-uri' =>
'/ns/share/1',
1390 $calendars = $backend->getCalendarsForUser(
'principals/user2');
1392 foreach ($expectedCalendar as $k => $v) {
1393 $this->assertEquals(
1396 "Key " . $k .
" in calendars array did not have the expected value." 1401 $backend->deleteCalendar($calendars[0][
'id']);
1403 $this->assertEquals(
1405 $backend->getCalendarsForUser(
'principals/user2')
1411 'href' =>
'principals/user1',
1412 'principal' =>
'principals/user1',
1413 'access' => \
Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER,
1414 'inviteStatus' => \
Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED,
1417 $this->assertEquals($expected, $result);
1426 $backend =
new PDO($this->pdo);
1427 $backend->setPublishStatus([1, 1],
true);
testGetCalendarsForUserNoCalendars()
testConstruct
testDeleteSubscriptions()
This class represents the {DAV:}sharee element.
testCalendarQueryTodoNotMatch()
testGetInvitesBadId()
testGetInvites
testCreateCalendarObjectDuration()
testCreateCalendarObject
testCreateCalendarObject()
This class represents a set of properties that are going to be updated.
testCreateSubscriptions()
testDeleteCalendarObjectBadId()
testDeleteCalendarObject
testDeleteCalendarBadID()
testCreateCalendarAndFetch
testUpdateInvitesBadId()
testUpdateInvites
testCalendarQueryNoFilter()
testDeleteCalendarObject()
testCreateCalendarObject
if(!array_key_exists('StateId', $_REQUEST)) $id
testGetCalendarObjectByUID()
testCreateCalendarObject
testUpdateCalendarObject()
testCreateCalendarObject
testCreateCalendarIncorrectComponentSet()
testCreateCalendarAndFetch
testCalendarQueryBadId()
testCalendarQueryNoResult
testUpdateInvitesNoPrincipal()
testUpdateInvites
dropTables($tableNames)
Drops tables, if they exist.
testDeleteSharedCalendar()
testUpdateInvites
testDeleteCalendar()
testCreateCalendarAndFetch
testCreateCalendarObjectNoComponent()
Sabre testCreateCalendarObject
const MAX_DATE
We need to specify a max date, because we need to stop somewhere
testCreateCalendarObjectNoDTEND()
testCreateCalendarObject
createSchema($schemaName)
Uses .sql files from the examples directory to initialize the database.
testGetChangesBadId()
testGetChanges
testCalendarQueryNoResult()
testUpdateSubscriptions()
schedule-calendar-transp property.
testGetCalendarObjects()
testCreateCalendarObject
testGetCalendarObjectBadId()
testGetCalendarObjects
testUpdateSubscriptionsFail()
getDb()
Returns a fully configured PDO object.
testUpdateCalendarBadId()
testConstruct
testCalendarQueryTimeRange()
testUpdateInvites()
testCreateCalendarAndFetch
testCreateCalendarObjectBadId()
testCreateCalendarObject
testUpdateCalendarUnknownProperty()
testUpdateCalendarAndFetch
testCreateCalendarAndFetch()
testConstruct
testCreateCalendarObjectInfiniteRecurrence()
testCreateCalendarObject
testCreateSubscriptionFail()
testCreateCalendarObjectEndingRecurrence()
testCreateCalendarObject
testCalendarQueryTimeRangeNoEnd()
testGetMultipleObjectsBadId()
testGetMultipleObjects
testUpdateCalendarAndFetch()
testConstruct
testGetCalendarObjectsBadId()
testGetCalendarObjects
testCreateCalendarObjectWithDTEND()
testCreateCalendarObject
testCreateCalendarObjectTask()
testCreateCalendarObject
testUpdateCalendarObjectBadId()
testUpdateCalendarObject