ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\VObject\Component\VAvailabilityTest Class Reference

We use RFCxxx has a placeholder for the https://tools.ietf.org/html/draft-daboo-calendar-availability-05 name. More...

+ Inheritance diagram for Sabre\VObject\Component\VAvailabilityTest:
+ Collaboration diagram for Sabre\VObject\Component\VAvailabilityTest:

Public Member Functions

 testVAvailabilityComponent ()
 
 testGetEffectiveStartEnd ()
 
 testGetEffectiveStartDuration ()
 
 testGetEffectiveStartEndUnbound ()
 
 testIsInTimeRangeUnbound ()
 
 testIsInTimeRangeOutside ()
 
 testRFCxxxSection3_1_availabilityprop_required ()
 
 testRFCxxxSection3_1_availabilityprop_optional_once ()
 
 testRFCxxxSection3_1_availabilityprop_dtend_duration ()
 
 testAvailableSubComponent ()
 
 testRFCxxxSection3_1_availableprop_required ()
 
 testRFCxxxSection3_1_available_dtend_duration ()
 
 testRFCxxxSection3_1_available_optional_once ()
 
 testRFCxxxSection3_2 ()
 

Protected Member Functions

 assertIsValid (VObject\Document $document)
 
 assertIsNotValid (VObject\Document $document)
 
 template (array $properties)
 
 templateAvailable (array $properties)
 
 _template ($template, array $properties)
 

Detailed Description

We use RFCxxx has a placeholder for the https://tools.ietf.org/html/draft-daboo-calendar-availability-05 name.

Definition at line 15 of file VAvailabilityTest.php.

Member Function Documentation

◆ _template()

Sabre\VObject\Component\VAvailabilityTest::_template (   $template,
array  $properties 
)
protected

Definition at line 485 of file VAvailabilityTest.php.

485 {
486
487 return str_replace('…', implode("\r\n", $properties), $template);
488
489 }
$template

References $template.

Referenced by Sabre\VObject\Component\VAvailabilityTest\template(), and Sabre\VObject\Component\VAvailabilityTest\templateAvailable().

+ Here is the caller graph for this function:

◆ assertIsNotValid()

◆ assertIsValid()

Sabre\VObject\Component\VAvailabilityTest::assertIsValid ( VObject\Document  $document)
protected

Definition at line 423 of file VAvailabilityTest.php.

423 {
424
425 $validationResult = $document->validate();
426 if ($validationResult) {
427 $messages = array_map(function($item) { return $item['message']; }, $validationResult);
428 $this->fail('Failed to assert that the supplied document is a valid document. Validation messages: ' . implode(', ', $messages));
429 }
430 $this->assertEmpty($document->validate());
431
432 }
$messages
Definition: en.php:5

References $messages.

Referenced by Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_availabilityprop_dtend_duration(), Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_availabilityprop_optional_once(), Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_availabilityprop_required(), Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_available_dtend_duration(), Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_available_optional_once(), and Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_availableprop_required().

+ Here is the caller graph for this function:

◆ template()

Sabre\VObject\Component\VAvailabilityTest::template ( array  $properties)
protected

Definition at line 440 of file VAvailabilityTest.php.

440 {
441
442 return $this->_template(
443 <<<VCAL
444BEGIN:VCALENDAR
445VERSION:2.0
446PRODID:-//id
447BEGIN:VAVAILABILITY
448UID:foo@test
449DTSTAMP:20111005T133225Z
450
451END:VAVAILABILITY
452END:VCALENDAR
453VCAL
454,
455 $properties
456 );
457
458 }
test()
Definition: build.php:107
_template($template, array $properties)

References Sabre\VObject\Component\VAvailabilityTest\_template(), and test().

+ Here is the call graph for this function:

◆ templateAvailable()

Sabre\VObject\Component\VAvailabilityTest::templateAvailable ( array  $properties)
protected

Definition at line 460 of file VAvailabilityTest.php.

460 {
461
462 return $this->_template(
463 <<<VCAL
464BEGIN:VCALENDAR
465VERSION:2.0
466PRODID:-//id
467BEGIN:VAVAILABILITY
468UID:foo@test
469DTSTAMP:20111005T133225Z
470BEGIN:AVAILABLE
471UID:foo@test
472DTSTAMP:20111005T133225Z
473DTSTART:20111005T133225Z
474
475END:AVAILABLE
476END:VAVAILABILITY
477END:VCALENDAR
478VCAL
479,
480 $properties
481 );
482
483 }

References Sabre\VObject\Component\VAvailabilityTest\_template(), and test().

Referenced by Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_available_dtend_duration(), Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_1_available_optional_once(), and Sabre\VObject\Component\VAvailabilityTest\testRFCxxxSection3_2().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testAvailableSubComponent()

Sabre\VObject\Component\VAvailabilityTest::testAvailableSubComponent ( )

Definition at line 235 of file VAvailabilityTest.php.

235 {
236
237 $vcal = <<<VCAL
238BEGIN:VCALENDAR
239BEGIN:VAVAILABILITY
240BEGIN:AVAILABLE
241END:AVAILABLE
242END:VAVAILABILITY
243END:VCALENDAR
244VCAL;
245 $document = Reader::read($vcal);
246
247 $this->assertInstanceOf(__NAMESPACE__, $document->VAVAILABILITY->AVAILABLE);
248
249 }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42

References $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testGetEffectiveStartDuration()

Sabre\VObject\Component\VAvailabilityTest::testGetEffectiveStartDuration ( )

Definition at line 54 of file VAvailabilityTest.php.

54 {
55
56 $vcal = <<<VCAL
57BEGIN:VCALENDAR
58BEGIN:VAVAILABILITY
59DTSTART:20150717T162200Z
60DURATION:PT1H
61END:VAVAILABILITY
62END:VCALENDAR
63VCAL;
64
65 $document = Reader::read($vcal);
66 $tz = new DateTimeZone('UTC');
67 $this->assertEquals(
68 [
69 new DateTimeImmutable('2015-07-17 16:22:00', $tz),
70 new DateTimeImmutable('2015-07-17 17:22:00', $tz),
71 ],
72 $document->VAVAILABILITY->getEffectiveStartEnd()
73 );
74
75 }

References $tz, $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testGetEffectiveStartEnd()

Sabre\VObject\Component\VAvailabilityTest::testGetEffectiveStartEnd ( )

Definition at line 31 of file VAvailabilityTest.php.

31 {
32
33 $vcal = <<<VCAL
34BEGIN:VCALENDAR
35BEGIN:VAVAILABILITY
36DTSTART:20150717T162200Z
37DTEND:20150717T172200Z
38END:VAVAILABILITY
39END:VCALENDAR
40VCAL;
41
42 $document = Reader::read($vcal);
43 $tz = new DateTimeZone('UTC');
44 $this->assertEquals(
45 [
46 new DateTimeImmutable('2015-07-17 16:22:00', $tz),
47 new DateTimeImmutable('2015-07-17 17:22:00', $tz),
48 ],
49 $document->VAVAILABILITY->getEffectiveStartEnd()
50 );
51
52 }

References $tz, $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testGetEffectiveStartEndUnbound()

Sabre\VObject\Component\VAvailabilityTest::testGetEffectiveStartEndUnbound ( )

Definition at line 77 of file VAvailabilityTest.php.

77 {
78
79 $vcal = <<<VCAL
80BEGIN:VCALENDAR
81BEGIN:VAVAILABILITY
82END:VAVAILABILITY
83END:VCALENDAR
84VCAL;
85
86 $document = Reader::read($vcal);
87 $this->assertEquals(
88 [
89 null,
90 null,
91 ],
92 $document->VAVAILABILITY->getEffectiveStartEnd()
93 );
94
95 }

References $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testIsInTimeRangeOutside()

Sabre\VObject\Component\VAvailabilityTest::testIsInTimeRangeOutside ( )

Definition at line 113 of file VAvailabilityTest.php.

113 {
114
115 $vcal = <<<VCAL
116BEGIN:VCALENDAR
117BEGIN:VAVAILABILITY
118DTSTART:20140101T000000Z
119DTEND:20140102T000000Z
120END:VAVAILABILITY
121END:VCALENDAR
122VCAL;
123
124 $document = Reader::read($vcal);
125 $this->assertFalse(
126 $document->VAVAILABILITY->isInTimeRange(new DateTimeImmutable('2015-07-17'), new DateTimeImmutable('2015-07-18'))
127 );
128
129 }

References $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testIsInTimeRangeUnbound()

Sabre\VObject\Component\VAvailabilityTest::testIsInTimeRangeUnbound ( )

Definition at line 97 of file VAvailabilityTest.php.

97 {
98
99 $vcal = <<<VCAL
100BEGIN:VCALENDAR
101BEGIN:VAVAILABILITY
102END:VAVAILABILITY
103END:VCALENDAR
104VCAL;
105
106 $document = Reader::read($vcal);
107 $this->assertTrue(
108 $document->VAVAILABILITY->isInTimeRange(new DateTimeImmutable('2015-07-17'), new DateTimeImmutable('2015-07-18'))
109 );
110
111 }

References $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_1_availabilityprop_dtend_duration()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_1_availabilityprop_dtend_duration ( )

Definition at line 216 of file VAvailabilityTest.php.

216 {
217
218 // Only DTEND.
219 $this->assertIsValid(Reader::read($this->template([
220 'DTEND:21111005T133225Z'
221 ])));
222
223 // Only DURATION.
224 $this->assertIsValid(Reader::read($this->template([
225 'DURATION:PT1H'
226 ])));
227
228 // Both (not allowed).
229 $this->assertIsNotValid(Reader::read($this->template([
230 'DTEND:21111005T133225Z',
231 'DURATION:PT1H'
232 ])));
233 }
assertIsNotValid(VObject\Document $document)

References Sabre\VObject\Component\VAvailabilityTest\assertIsNotValid(), Sabre\VObject\Component\VAvailabilityTest\assertIsValid(), and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_1_availabilityprop_optional_once()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_1_availabilityprop_optional_once ( )

Definition at line 187 of file VAvailabilityTest.php.

187 {
188
189 $properties = [
190 'BUSYTYPE:BUSY',
191 'CLASS:PUBLIC',
192 'CREATED:20111005T135125Z',
193 'DESCRIPTION:Long bla bla',
194 'DTSTART:20111005T020000',
195 'LAST-MODIFIED:20111005T135325Z',
196 'ORGANIZER:mailto:foo@example.com',
197 'PRIORITY:1',
198 'SEQUENCE:0',
199 'SUMMARY:Bla bla',
200 'URL:http://example.org/'
201 ];
202
203 // They are all present, only once.
204 $this->assertIsValid(Reader::read($this->template($properties)));
205
206 // We duplicate each one to see if it fails.
207 foreach ($properties as $property) {
208 $this->assertIsNotValid(Reader::read($this->template([
209 $property,
210 $property
211 ])));
212 }
213
214 }

References Sabre\VObject\Component\VAvailabilityTest\assertIsNotValid(), Sabre\VObject\Component\VAvailabilityTest\assertIsValid(), and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_1_availabilityprop_required()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_1_availabilityprop_required ( )

Definition at line 131 of file VAvailabilityTest.php.

131 {
132
133 // UID and DTSTAMP are present.
135<<<VCAL
136BEGIN:VCALENDAR
137VERSION:2.0
138PRODID:-//id
139BEGIN:VAVAILABILITY
140UID:foo@test
141DTSTAMP:20111005T133225Z
142END:VAVAILABILITY
143END:VCALENDAR
144VCAL
145 ));
146
147 // UID and DTSTAMP are missing.
149<<<VCAL
150BEGIN:VCALENDAR
151VERSION:2.0
152PRODID:-//id
153BEGIN:VAVAILABILITY
154END:VAVAILABILITY
155END:VCALENDAR
156VCAL
157 ));
158
159 // DTSTAMP is missing.
161<<<VCAL
162BEGIN:VCALENDAR
163VERSION:2.0
164PRODID:-//id
165BEGIN:VAVAILABILITY
166UID:foo@test
167END:VAVAILABILITY
168END:VCALENDAR
169VCAL
170 ));
171
172 // UID is missing.
174<<<VCAL
175BEGIN:VCALENDAR
176VERSION:2.0
177PRODID:-//id
178BEGIN:VAVAILABILITY
179DTSTAMP:20111005T133225Z
180END:VAVAILABILITY
181END:VCALENDAR
182VCAL
183 ));
184
185 }

References Sabre\VObject\Component\VAvailabilityTest\assertIsNotValid(), Sabre\VObject\Component\VAvailabilityTest\assertIsValid(), Sabre\VObject\Reader\read(), and test().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_1_available_dtend_duration()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_1_available_dtend_duration ( )

Definition at line 344 of file VAvailabilityTest.php.

344 {
345
346 // Only DTEND.
348 'DTEND:21111005T133225Z'
349 ])));
350
351 // Only DURATION.
353 'DURATION:PT1H'
354 ])));
355
356 // Both (not allowed).
358 'DTEND:21111005T133225Z',
359 'DURATION:PT1H'
360 ])));
361 }

References Sabre\VObject\Component\VAvailabilityTest\assertIsNotValid(), Sabre\VObject\Component\VAvailabilityTest\assertIsValid(), Sabre\VObject\Reader\read(), and Sabre\VObject\Component\VAvailabilityTest\templateAvailable().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_1_available_optional_once()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_1_available_optional_once ( )

Definition at line 363 of file VAvailabilityTest.php.

363 {
364
365 $properties = [
366 'CREATED:20111005T135125Z',
367 'DESCRIPTION:Long bla bla',
368 'LAST-MODIFIED:20111005T135325Z',
369 'RECURRENCE-ID;RANGE=THISANDFUTURE:19980401T133000Z',
370 'RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
371 'SUMMARY:Bla bla'
372 ];
373
374 // They are all present, only once.
375 $this->assertIsValid(Reader::read($this->templateAvailable($properties)));
376
377 // We duplicate each one to see if it fails.
378 foreach ($properties as $property) {
380 $property,
381 $property
382 ])));
383 }
384
385 }

References Sabre\VObject\Component\VAvailabilityTest\assertIsNotValid(), Sabre\VObject\Component\VAvailabilityTest\assertIsValid(), Sabre\VObject\Reader\read(), and Sabre\VObject\Component\VAvailabilityTest\templateAvailable().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_1_availableprop_required()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_1_availableprop_required ( )

Definition at line 251 of file VAvailabilityTest.php.

251 {
252
253 // UID, DTSTAMP and DTSTART are present.
255<<<VCAL
256BEGIN:VCALENDAR
257VERSION:2.0
258PRODID:-//id
259BEGIN:VAVAILABILITY
260UID:foo@test
261DTSTAMP:20111005T133225Z
262BEGIN:AVAILABLE
263UID:foo@test
264DTSTAMP:20111005T133225Z
265DTSTART:20111005T133225Z
266END:AVAILABLE
267END:VAVAILABILITY
268END:VCALENDAR
269VCAL
270 ));
271
272 // UID, DTSTAMP and DTSTART are missing.
274<<<VCAL
275BEGIN:VCALENDAR
276VERSION:2.0
277PRODID:-//id
278BEGIN:VAVAILABILITY
279UID:foo@test
280DTSTAMP:20111005T133225Z
281BEGIN:AVAILABLE
282END:AVAILABLE
283END:VAVAILABILITY
284END:VCALENDAR
285VCAL
286 ));
287
288 // UID is missing.
290<<<VCAL
291BEGIN:VCALENDAR
292VERSION:2.0
293PRODID:-//id
294BEGIN:VAVAILABILITY
295UID:foo@test
296DTSTAMP:20111005T133225Z
297BEGIN:AVAILABLE
298DTSTAMP:20111005T133225Z
299DTSTART:20111005T133225Z
300END:AVAILABLE
301END:VAVAILABILITY
302END:VCALENDAR
303VCAL
304 ));
305
306 // DTSTAMP is missing.
308<<<VCAL
309BEGIN:VCALENDAR
310VERSION:2.0
311PRODID:-//id
312BEGIN:VAVAILABILITY
313UID:foo@test
314DTSTAMP:20111005T133225Z
315BEGIN:AVAILABLE
316UID:foo@test
317DTSTART:20111005T133225Z
318END:AVAILABLE
319END:VAVAILABILITY
320END:VCALENDAR
321VCAL
322 ));
323
324 // DTSTART is missing.
326<<<VCAL
327BEGIN:VCALENDAR
328VERSION:2.0
329PRODID:-//id
330BEGIN:VAVAILABILITY
331UID:foo@test
332DTSTAMP:20111005T133225Z
333BEGIN:AVAILABLE
334UID:foo@test
335DTSTAMP:20111005T133225Z
336END:AVAILABLE
337END:VAVAILABILITY
338END:VCALENDAR
339VCAL
340 ));
341
342 }

References Sabre\VObject\Component\VAvailabilityTest\assertIsNotValid(), Sabre\VObject\Component\VAvailabilityTest\assertIsValid(), Sabre\VObject\Reader\read(), and test().

+ Here is the call graph for this function:

◆ testRFCxxxSection3_2()

Sabre\VObject\Component\VAvailabilityTest::testRFCxxxSection3_2 ( )

Definition at line 386 of file VAvailabilityTest.php.

386 {
387
388 $this->assertEquals(
389 'BUSY',
391 'BUSYTYPE:BUSY'
392 ]))
393 ->VAVAILABILITY
394 ->AVAILABLE
395 ->BUSYTYPE
396 ->getValue()
397 );
398
399 $this->assertEquals(
400 'BUSY-UNAVAILABLE',
402 'BUSYTYPE:BUSY-UNAVAILABLE'
403 ]))
404 ->VAVAILABILITY
405 ->AVAILABLE
406 ->BUSYTYPE
407 ->getValue()
408 );
409
410 $this->assertEquals(
411 'BUSY-TENTATIVE',
413 'BUSYTYPE:BUSY-TENTATIVE'
414 ]))
415 ->VAVAILABILITY
416 ->AVAILABLE
417 ->BUSYTYPE
418 ->getValue()
419 );
420
421 }

References Sabre\VObject\Reader\read(), and Sabre\VObject\Component\VAvailabilityTest\templateAvailable().

+ Here is the call graph for this function:

◆ testVAvailabilityComponent()

Sabre\VObject\Component\VAvailabilityTest::testVAvailabilityComponent ( )

Definition at line 17 of file VAvailabilityTest.php.

17 {
18
19 $vcal = <<<VCAL
20BEGIN:VCALENDAR
21BEGIN:VAVAILABILITY
22END:VAVAILABILITY
23END:VCALENDAR
24VCAL;
25 $document = Reader::read($vcal);
26
27 $this->assertInstanceOf(__NAMESPACE__ . '\VAvailability', $document->VAVAILABILITY);
28
29 }

References $vcal, and Sabre\VObject\Reader\read().

+ Here is the call graph for this function:

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