ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\Backend\SimplePDOTest Class Reference
+ Inheritance diagram for Sabre\CalDAV\Backend\SimplePDOTest:
+ Collaboration diagram for Sabre\CalDAV\Backend\SimplePDOTest:

Public Member Functions

 setUp ()
 
 testConstruct ()
 
 testGetCalendarsForUserNoCalendars ()
 @depends testConstruct More...
 
 testCreateCalendarAndFetch ()
 @depends testConstruct More...
 
 testUpdateCalendarAndFetch ()
 @depends testConstruct More...
 
 testDeleteCalendar ()
 @depends testCreateCalendarAndFetch More...
 
 testCreateCalendarObject ()
 
 testGetMultipleObjects ()
 
 testGetCalendarObjects ()
 @depends testCreateCalendarObject More...
 
 testGetCalendarObjectByUID ()
 @depends testCreateCalendarObject More...
 
 testUpdateCalendarObject ()
 @depends testCreateCalendarObject More...
 
 testDeleteCalendarObject ()
 @depends testCreateCalendarObject More...
 
 testCalendarQueryNoResult ()
 
 testCalendarQueryTodo ()
 
 testCalendarQueryTodoNotMatch ()
 
 testCalendarQueryNoFilter ()
 
 testCalendarQueryTimeRange ()
 
 testCalendarQueryTimeRangeNoEnd ()
 

Protected Attributes

 $pdo
 

Detailed Description

Definition at line 9 of file SimplePDOTest.php.

Member Function Documentation

◆ setUp()

Sabre\CalDAV\Backend\SimplePDOTest::setUp ( )

Definition at line 13 of file SimplePDOTest.php.

13 {
14
15 if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
16
17 if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite'))
18 unlink(SABRE_TEMPDIR . '/testdb.sqlite');
19
20 $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite');
21 $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
22
23 $pdo->exec(<<<SQL
24CREATE TABLE simple_calendars (
25 id INTEGER PRIMARY KEY ASC NOT NULL,
26 uri TEXT NOT NULL,
27 principaluri TEXT NOT NULL
28)
29SQL
30 );
31 $pdo->exec(<<<SQL
32CREATE TABLE simple_calendarobjects (
33 id INTEGER PRIMARY KEY ASC NOT NULL,
34 calendarid INT UNSIGNED NOT NULL,
35 uri TEXT NOT NULL,
36 calendardata TEXT
37);
38SQL
39 );
40
41 $this->pdo = $pdo;
42
43 }

References Sabre\CalDAV\Backend\SimplePDOTest\$pdo.

◆ testCalendarQueryNoFilter()

Sabre\CalDAV\Backend\SimplePDOTest::testCalendarQueryNoFilter ( )

Definition at line 362 of file SimplePDOTest.php.

362 {
363
364 $backend = new SimplePDO($this->pdo);
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");
367
368 $filters = [
369 'name' => 'VCALENDAR',
370 'comp-filters' => [],
371 'prop-filters' => [],
372 'is-not-defined' => false,
373 'time-range' => null,
374 ];
375
376 $result = $backend->calendarQuery(1, $filters);
377 $this->assertTrue(in_array('todo', $result));
378 $this->assertTrue(in_array('event', $result));
379
380 }
$result

References $result.

◆ testCalendarQueryNoResult()

Sabre\CalDAV\Backend\SimplePDOTest::testCalendarQueryNoResult ( )

Definition at line 276 of file SimplePDOTest.php.

276 {
277
278 $abstract = new SimplePDO($this->pdo);
279 $filters = [
280 'name' => 'VCALENDAR',
281 'comp-filters' => [
282 [
283 'name' => 'VJOURNAL',
284 'comp-filters' => [],
285 'prop-filters' => [],
286 'is-not-defined' => false,
287 'time-range' => null,
288 ],
289 ],
290 'prop-filters' => [],
291 'is-not-defined' => false,
292 'time-range' => null,
293 ];
294
295 $this->assertEquals([
296 ], $abstract->calendarQuery(1, $filters));
297
298 }

◆ testCalendarQueryTimeRange()

Sabre\CalDAV\Backend\SimplePDOTest::testCalendarQueryTimeRange ( )

Definition at line 382 of file SimplePDOTest.php.

382 {
383
384 $backend = new SimplePDO($this->pdo);
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");
388
389 $filters = [
390 'name' => 'VCALENDAR',
391 'comp-filters' => [
392 [
393 'name' => 'VEVENT',
394 'comp-filters' => [],
395 'prop-filters' => [],
396 'is-not-defined' => false,
397 'time-range' => [
398 'start' => new \DateTime('20120103'),
399 'end' => new \DateTime('20120104'),
400 ],
401 ],
402 ],
403 'prop-filters' => [],
404 'is-not-defined' => false,
405 'time-range' => null,
406 ];
407
408 $this->assertEquals([
409 "event2",
410 ], $backend->calendarQuery(1, $filters));
411
412 }

◆ testCalendarQueryTimeRangeNoEnd()

Sabre\CalDAV\Backend\SimplePDOTest::testCalendarQueryTimeRangeNoEnd ( )

Definition at line 413 of file SimplePDOTest.php.

413 {
414
415 $backend = new SimplePDO($this->pdo);
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");
419
420 $filters = [
421 'name' => 'VCALENDAR',
422 'comp-filters' => [
423 [
424 'name' => 'VEVENT',
425 'comp-filters' => [],
426 'prop-filters' => [],
427 'is-not-defined' => false,
428 'time-range' => [
429 'start' => new \DateTime('20120102'),
430 'end' => null,
431 ],
432 ],
433 ],
434 'prop-filters' => [],
435 'is-not-defined' => false,
436 'time-range' => null,
437 ];
438
439 $this->assertEquals([
440 "event2",
441 ], $backend->calendarQuery(1, $filters));
442
443 }

◆ testCalendarQueryTodo()

Sabre\CalDAV\Backend\SimplePDOTest::testCalendarQueryTodo ( )

Definition at line 300 of file SimplePDOTest.php.

300 {
301
302 $backend = new SimplePDO($this->pdo);
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");
305
306 $filters = [
307 'name' => 'VCALENDAR',
308 'comp-filters' => [
309 [
310 'name' => 'VTODO',
311 'comp-filters' => [],
312 'prop-filters' => [],
313 'is-not-defined' => false,
314 'time-range' => null,
315 ],
316 ],
317 'prop-filters' => [],
318 'is-not-defined' => false,
319 'time-range' => null,
320 ];
321
322 $this->assertEquals([
323 "todo",
324 ], $backend->calendarQuery(1, $filters));
325
326 }

◆ testCalendarQueryTodoNotMatch()

Sabre\CalDAV\Backend\SimplePDOTest::testCalendarQueryTodoNotMatch ( )

Definition at line 327 of file SimplePDOTest.php.

327 {
328
329 $backend = new SimplePDO($this->pdo);
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");
332
333 $filters = [
334 'name' => 'VCALENDAR',
335 'comp-filters' => [
336 [
337 'name' => 'VTODO',
338 'comp-filters' => [],
339 'prop-filters' => [
340 [
341 'name' => 'summary',
342 'text-match' => null,
343 'time-range' => null,
344 'param-filters' => [],
345 'is-not-defined' => false,
346 ],
347 ],
348 'is-not-defined' => false,
349 'time-range' => null,
350 ],
351 ],
352 'prop-filters' => [],
353 'is-not-defined' => false,
354 'time-range' => null,
355 ];
356
357 $this->assertEquals([
358 ], $backend->calendarQuery(1, $filters));
359
360 }

◆ testConstruct()

Sabre\CalDAV\Backend\SimplePDOTest::testConstruct ( )

Definition at line 45 of file SimplePDOTest.php.

45 {
46
47 $backend = new SimplePDO($this->pdo);
48 $this->assertTrue($backend instanceof SimplePDO);
49
50 }

◆ testCreateCalendarAndFetch()

Sabre\CalDAV\Backend\SimplePDOTest::testCreateCalendarAndFetch ( )

@depends testConstruct

Definition at line 66 of file SimplePDOTest.php.

66 {
67
68 $backend = new SimplePDO($this->pdo);
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'),
73 ]);
74 $calendars = $backend->getCalendarsForUser('principals/user2');
75
76 $elementCheck = [
77 'uri' => 'somerandomid',
78 ];
79
80 $this->assertInternalType('array', $calendars);
81 $this->assertEquals(1, count($calendars));
82
83 foreach ($elementCheck as $name => $value) {
84
85 $this->assertArrayHasKey($name, $calendars[0]);
86 $this->assertEquals($value, $calendars[0][$name]);
87
88 }
89
90 }

References $name.

◆ testCreateCalendarObject()

Sabre\CalDAV\Backend\SimplePDOTest::testCreateCalendarObject ( )

Definition at line 134 of file SimplePDOTest.php.

134 {
135
136 $backend = new SimplePDO($this->pdo);
137 $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
138
139 $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
140
141 $backend->createCalendarObject($returnedId, 'random-id', $object);
142
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));
147
148 }

References $result.

◆ testDeleteCalendar()

Sabre\CalDAV\Backend\SimplePDOTest::testDeleteCalendar ( )

@depends testCreateCalendarAndFetch

Definition at line 119 of file SimplePDOTest.php.

119 {
120
121 $backend = new SimplePDO($this->pdo);
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!',
125 ]);
126
127 $backend->deleteCalendar($returnedId);
128
129 $calendars = $backend->getCalendarsForUser('principals/user2');
130 $this->assertEquals([], $calendars);
131
132 }

◆ testDeleteCalendarObject()

Sabre\CalDAV\Backend\SimplePDOTest::testDeleteCalendarObject ( )

@depends testCreateCalendarObject

Definition at line 261 of file SimplePDOTest.php.

261 {
262
263 $backend = new SimplePDO($this->pdo);
264 $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
265
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');
269
270 $data = $backend->getCalendarObject($returnedId, 'random-id');
271 $this->assertNull($data);
272
273 }
$data
Definition: bench.php:6

References $data.

◆ testGetCalendarObjectByUID()

Sabre\CalDAV\Backend\SimplePDOTest::testGetCalendarObjectByUID ( )

@depends testCreateCalendarObject

Definition at line 218 of file SimplePDOTest.php.

218 {
219
220 $backend = new SimplePDO($this->pdo);
221 $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
222
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);
225
226 $this->assertNull(
227 $backend->getCalendarObjectByUID('principals/user2', 'bar')
228 );
229 $this->assertEquals(
230 'somerandomid/random-id',
231 $backend->getCalendarObjectByUID('principals/user2', 'foo')
232 );
233
234 }

◆ testGetCalendarObjects()

Sabre\CalDAV\Backend\SimplePDOTest::testGetCalendarObjects ( )

@depends testCreateCalendarObject

Definition at line 197 of file SimplePDOTest.php.

197 {
198
199 $backend = new SimplePDO($this->pdo);
200 $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
201
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);
204
205 $data = $backend->getCalendarObjects($returnedId);
206
207 $this->assertEquals(1, count($data));
208 $data = $data[0];
209
210 $this->assertEquals('random-id', $data['uri']);
211 $this->assertEquals(strlen($object), $data['size']);
212
213 }

References $data.

◆ testGetCalendarsForUserNoCalendars()

Sabre\CalDAV\Backend\SimplePDOTest::testGetCalendarsForUserNoCalendars ( )

@depends testConstruct

Definition at line 55 of file SimplePDOTest.php.

55 {
56
57 $backend = new SimplePDO($this->pdo);
58 $calendars = $backend->getCalendarsForUser('principals/user2');
59 $this->assertEquals([], $calendars);
60
61 }

◆ testGetMultipleObjects()

Sabre\CalDAV\Backend\SimplePDOTest::testGetMultipleObjects ( )

Definition at line 149 of file SimplePDOTest.php.

149 {
150
151 $backend = new SimplePDO($this->pdo);
152 $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
153
154 $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
155
156 $backend->createCalendarObject($returnedId, 'id-1', $object);
157 $backend->createCalendarObject($returnedId, 'id-2', $object);
158
159 $check = [
160 [
161 'id' => 1,
162 'etag' => '"' . md5($object) . '"',
163 'uri' => 'id-1',
164 'size' => strlen($object),
165 'calendardata' => $object,
166 ],
167 [
168 'id' => 2,
169 'etag' => '"' . md5($object) . '"',
170 'uri' => 'id-2',
171 'size' => strlen($object),
172 'calendardata' => $object,
173 ],
174 ];
175
176 $result = $backend->getMultipleCalendarObjects($returnedId, ['id-1', 'id-2']);
177
178 foreach ($check as $index => $props) {
179
180 foreach ($props as $key => $value) {
181
182 if ($key !== 'lastmodified') {
183 $this->assertEquals($value, $result[$index][$key]);
184 } else {
185 $this->assertTrue(isset($result[$index][$key]));
186 }
187
188 }
189
190 }
191
192 }
$key
Definition: croninfo.php:18
$index
Definition: metadata.php:60

References $index, $key, and $result.

◆ testUpdateCalendarAndFetch()

Sabre\CalDAV\Backend\SimplePDOTest::testUpdateCalendarAndFetch ( )

@depends testConstruct

Definition at line 95 of file SimplePDOTest.php.

95 {
96
97 $backend = new SimplePDO($this->pdo);
98
99 //Creating a new calendar
100 $newId = $backend->createCalendar('principals/user2', 'somerandomid', []);
101
102 $propPatch = new PropPatch([
103 '{DAV:}displayname' => 'myCalendar',
104 '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'),
105 ]);
106
107 // Updating the calendar
108 $backend->updateCalendar($newId, $propPatch);
109 $result = $propPatch->commit();
110
111 // Verifying the result of the update
112 $this->assertFalse($result);
113
114 }

References $result.

◆ testUpdateCalendarObject()

Sabre\CalDAV\Backend\SimplePDOTest::testUpdateCalendarObject ( )

@depends testCreateCalendarObject

Definition at line 239 of file SimplePDOTest.php.

239 {
240
241 $backend = new SimplePDO($this->pdo);
242 $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
243
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);
248
249 $data = $backend->getCalendarObject($returnedId, 'random-id');
250
251 $this->assertEquals($object2, $data['calendardata']);
252 $this->assertEquals('random-id', $data['uri']);
253
254
255 }

References $data.

Field Documentation

◆ $pdo

Sabre\CalDAV\Backend\SimplePDOTest::$pdo
protected

Definition at line 11 of file SimplePDOTest.php.

Referenced by Sabre\CalDAV\Backend\SimplePDOTest\setUp().


The documentation for this class was generated from the following file: