15 if (!SABRE_HASSQLITE) $this->markTestSkipped(
'SQLite driver is not available');
17 if (file_exists(SABRE_TEMPDIR .
'/testdb.sqlite'))
18 unlink(SABRE_TEMPDIR .
'/testdb.sqlite');
20 $pdo = new \PDO(
'sqlite:' . SABRE_TEMPDIR .
'/testdb.sqlite');
21 $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
24 CREATE TABLE simple_calendars (
25 id INTEGER PRIMARY KEY ASC NOT NULL,
27 principaluri TEXT NOT NULL
32 CREATE TABLE simple_calendarobjects (
33 id INTEGER PRIMARY KEY ASC NOT NULL,
34 calendarid INT UNSIGNED NOT NULL,
48 $this->assertTrue($backend instanceof
SimplePDO);
58 $calendars = $backend->getCalendarsForUser(
'principals/user2');
59 $this->assertEquals([], $calendars);
69 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', [
70 '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' =>
new CalDAV\Xml\
Property\SupportedCalendarComponentSet([
'VEVENT']),
71 '{DAV:}displayname' =>
'Hello!',
72 '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' =>
new CalDAV\Xml\
Property\ScheduleCalendarTransp(
'transparent'),
74 $calendars = $backend->getCalendarsForUser(
'principals/user2');
77 'uri' =>
'somerandomid',
80 $this->assertInternalType(
'array', $calendars);
81 $this->assertEquals(1, count($calendars));
83 foreach ($elementCheck as
$name => $value) {
85 $this->assertArrayHasKey(
$name, $calendars[0]);
86 $this->assertEquals($value, $calendars[0][
$name]);
100 $newId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
103 '{DAV:}displayname' =>
'myCalendar',
104 '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' =>
new CalDAV\Xml\
Property\ScheduleCalendarTransp(
'transparent'),
108 $backend->updateCalendar($newId, $propPatch);
109 $result = $propPatch->commit();
122 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', [
123 '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' =>
new CalDAV\Xml\
Property\SupportedCalendarComponentSet([
'VEVENT']),
124 '{DAV:}displayname' =>
'Hello!',
127 $backend->deleteCalendar($returnedId);
129 $calendars = $backend->getCalendarsForUser(
'principals/user2');
130 $this->assertEquals([], $calendars);
137 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
139 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
141 $backend->createCalendarObject($returnedId,
'random-id', $object);
143 $result = $this->pdo->query(
'SELECT calendardata FROM simple_calendarobjects WHERE uri = "random-id"');
144 $this->assertEquals([
145 'calendardata' => $object,
146 ],
$result->fetch(\PDO::FETCH_ASSOC));
152 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
154 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
156 $backend->createCalendarObject($returnedId,
'id-1', $object);
157 $backend->createCalendarObject($returnedId,
'id-2', $object);
162 'etag' =>
'"' . md5($object) .
'"',
164 'size' => strlen($object),
165 'calendardata' => $object,
169 'etag' =>
'"' . md5($object) .
'"',
171 'size' => strlen($object),
172 'calendardata' => $object,
176 $result = $backend->getMultipleCalendarObjects($returnedId, [
'id-1',
'id-2']);
178 foreach ($check as
$index => $props) {
180 foreach ($props as
$key => $value) {
182 if (
$key !==
'lastmodified') {
200 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
202 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
203 $backend->createCalendarObject($returnedId,
'random-id', $object);
205 $data = $backend->getCalendarObjects($returnedId);
207 $this->assertEquals(1, count(
$data));
210 $this->assertEquals(
'random-id',
$data[
'uri']);
211 $this->assertEquals(strlen($object),
$data[
'size']);
221 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
223 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
224 $backend->createCalendarObject($returnedId,
'random-id', $object);
227 $backend->getCalendarObjectByUID(
'principals/user2',
'bar')
230 'somerandomid/random-id',
231 $backend->getCalendarObjectByUID(
'principals/user2',
'foo')
242 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
244 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
245 $object2 =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20130101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
246 $backend->createCalendarObject($returnedId,
'random-id', $object);
247 $backend->updateCalendarObject($returnedId,
'random-id', $object2);
249 $data = $backend->getCalendarObject($returnedId,
'random-id');
251 $this->assertEquals($object2,
$data[
'calendardata']);
252 $this->assertEquals(
'random-id',
$data[
'uri']);
264 $returnedId = $backend->createCalendar(
'principals/user2',
'somerandomid', []);
266 $object =
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
267 $backend->createCalendarObject($returnedId,
'random-id', $object);
268 $backend->deleteCalendarObject($returnedId,
'random-id');
270 $data = $backend->getCalendarObject($returnedId,
'random-id');
271 $this->assertNull(
$data);
280 'name' =>
'VCALENDAR',
283 'name' =>
'VJOURNAL',
284 'comp-filters' => [],
285 'prop-filters' => [],
286 'is-not-defined' =>
false,
287 'time-range' => null,
290 'prop-filters' => [],
291 'is-not-defined' =>
false,
292 'time-range' => null,
295 $this->assertEquals([
296 ], $abstract->calendarQuery(1, $filters));
303 $backend->createCalendarObject(1,
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
304 $backend->createCalendarObject(1,
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
307 'name' =>
'VCALENDAR',
311 'comp-filters' => [],
312 'prop-filters' => [],
313 'is-not-defined' =>
false,
314 'time-range' => null,
317 'prop-filters' => [],
318 'is-not-defined' =>
false,
319 'time-range' => null,
322 $this->assertEquals([
324 ], $backend->calendarQuery(1, $filters));
330 $backend->createCalendarObject(1,
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
331 $backend->createCalendarObject(1,
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
334 'name' =>
'VCALENDAR',
338 'comp-filters' => [],
342 'text-match' => null,
343 'time-range' => null,
344 'param-filters' => [],
345 'is-not-defined' =>
false,
348 'is-not-defined' =>
false,
349 'time-range' => null,
352 'prop-filters' => [],
353 'is-not-defined' =>
false,
354 'time-range' => null,
357 $this->assertEquals([
358 ], $backend->calendarQuery(1, $filters));
365 $backend->createCalendarObject(1,
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
366 $backend->createCalendarObject(1,
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
369 'name' =>
'VCALENDAR',
370 'comp-filters' => [],
371 'prop-filters' => [],
372 'is-not-defined' =>
false,
373 'time-range' => null,
376 $result = $backend->calendarQuery(1, $filters);
377 $this->assertTrue(in_array(
'todo',
$result));
378 $this->assertTrue(in_array(
'event',
$result));
385 $backend->createCalendarObject(1,
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
386 $backend->createCalendarObject(1,
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
387 $backend->createCalendarObject(1,
"event2",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
390 'name' =>
'VCALENDAR',
394 'comp-filters' => [],
395 'prop-filters' => [],
396 'is-not-defined' =>
false,
398 'start' => new \DateTime(
'20120103'),
399 'end' => new \DateTime(
'20120104'),
403 'prop-filters' => [],
404 'is-not-defined' =>
false,
405 'time-range' => null,
408 $this->assertEquals([
410 ], $backend->calendarQuery(1, $filters));
416 $backend->createCalendarObject(1,
"todo",
"BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
417 $backend->createCalendarObject(1,
"event",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
418 $backend->createCalendarObject(1,
"event2",
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
421 'name' =>
'VCALENDAR',
425 'comp-filters' => [],
426 'prop-filters' => [],
427 'is-not-defined' =>
false,
429 'start' => new \DateTime(
'20120102'),
434 'prop-filters' => [],
435 'is-not-defined' =>
false,
436 'time-range' => null,
439 $this->assertEquals([
441 ], $backend->calendarQuery(1, $filters));
testDeleteCalendar()
testCreateCalendarAndFetch
This class represents a set of properties that are going to be updated.
testDeleteCalendarObject()
testCreateCalendarObject
testUpdateCalendarAndFetch()
testConstruct
testCalendarQueryTimeRange()
testCalendarQueryNoResult()
testCreateCalendarObject()
Simple PDO CalDAV backend.
testUpdateCalendarObject()
testCreateCalendarObject
testGetCalendarsForUserNoCalendars()
testConstruct
testCalendarQueryNoFilter()
testGetCalendarObjectByUID()
testCreateCalendarObject
testCalendarQueryTodoNotMatch()
testCalendarQueryTimeRangeNoEnd()
testGetCalendarObjects()
testCreateCalendarObject
testCreateCalendarAndFetch()
testConstruct