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.

References $template.

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

485  {
486 
487  return str_replace('…', implode("\r\n", $properties), $template);
488 
489  }
$template
+ 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.

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().

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
+ 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.

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

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

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().

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

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

235  {
236 
237  $vcal = <<<VCAL
238 BEGIN:VCALENDAR
239 BEGIN:VAVAILABILITY
240 BEGIN:AVAILABLE
241 END:AVAILABLE
242 END:VAVAILABILITY
243 END:VCALENDAR
244 VCAL;
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
+ Here is the call graph for this function:

◆ testGetEffectiveStartDuration()

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

Definition at line 54 of file VAvailabilityTest.php.

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

54  {
55 
56  $vcal = <<<VCAL
57 BEGIN:VCALENDAR
58 BEGIN:VAVAILABILITY
59 DTSTART:20150717T162200Z
60 DURATION:PT1H
61 END:VAVAILABILITY
62 END:VCALENDAR
63 VCAL;
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  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

◆ testGetEffectiveStartEnd()

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

Definition at line 31 of file VAvailabilityTest.php.

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

31  {
32 
33  $vcal = <<<VCAL
34 BEGIN:VCALENDAR
35 BEGIN:VAVAILABILITY
36 DTSTART:20150717T162200Z
37 DTEND:20150717T172200Z
38 END:VAVAILABILITY
39 END:VCALENDAR
40 VCAL;
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  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

◆ testGetEffectiveStartEndUnbound()

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

Definition at line 77 of file VAvailabilityTest.php.

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

77  {
78 
79  $vcal = <<<VCAL
80 BEGIN:VCALENDAR
81 BEGIN:VAVAILABILITY
82 END:VAVAILABILITY
83 END:VCALENDAR
84 VCAL;
85 
86  $document = Reader::read($vcal);
87  $this->assertEquals(
88  [
89  null,
90  null,
91  ],
92  $document->VAVAILABILITY->getEffectiveStartEnd()
93  );
94 
95  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

◆ testIsInTimeRangeOutside()

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

Definition at line 113 of file VAvailabilityTest.php.

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

113  {
114 
115  $vcal = <<<VCAL
116 BEGIN:VCALENDAR
117 BEGIN:VAVAILABILITY
118 DTSTART:20140101T000000Z
119 DTEND:20140102T000000Z
120 END:VAVAILABILITY
121 END:VCALENDAR
122 VCAL;
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  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

◆ testIsInTimeRangeUnbound()

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

Definition at line 97 of file VAvailabilityTest.php.

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

97  {
98 
99  $vcal = <<<VCAL
100 BEGIN:VCALENDAR
101 BEGIN:VAVAILABILITY
102 END:VAVAILABILITY
103 END:VCALENDAR
104 VCAL;
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  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ 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.

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

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)
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ 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.

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

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  }
assertIsNotValid(VObject\Document $document)
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ 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.

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

131  {
132 
133  // UID and DTSTAMP are present.
135 <<<VCAL
136 BEGIN:VCALENDAR
137 VERSION:2.0
138 PRODID:-//id
139 BEGIN:VAVAILABILITY
140 UID:foo@test
141 DTSTAMP:20111005T133225Z
142 END:VAVAILABILITY
143 END:VCALENDAR
144 VCAL
145  ));
146 
147  // UID and DTSTAMP are missing.
149 <<<VCAL
150 BEGIN:VCALENDAR
151 VERSION:2.0
152 PRODID:-//id
153 BEGIN:VAVAILABILITY
154 END:VAVAILABILITY
155 END:VCALENDAR
156 VCAL
157  ));
158 
159  // DTSTAMP is missing.
161 <<<VCAL
162 BEGIN:VCALENDAR
163 VERSION:2.0
164 PRODID:-//id
165 BEGIN:VAVAILABILITY
166 UID:foo@test
167 END:VAVAILABILITY
168 END:VCALENDAR
169 VCAL
170  ));
171 
172  // UID is missing.
174 <<<VCAL
175 BEGIN:VCALENDAR
176 VERSION:2.0
177 PRODID:-//id
178 BEGIN:VAVAILABILITY
179 DTSTAMP:20111005T133225Z
180 END:VAVAILABILITY
181 END:VCALENDAR
182 VCAL
183  ));
184 
185  }
assertIsNotValid(VObject\Document $document)
test()
Definition: build.php:107
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ 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.

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

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  }
assertIsNotValid(VObject\Document $document)
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ 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.

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

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  }
assertIsNotValid(VObject\Document $document)
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ 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.

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

251  {
252 
253  // UID, DTSTAMP and DTSTART are present.
255 <<<VCAL
256 BEGIN:VCALENDAR
257 VERSION:2.0
258 PRODID:-//id
259 BEGIN:VAVAILABILITY
260 UID:foo@test
261 DTSTAMP:20111005T133225Z
262 BEGIN:AVAILABLE
263 UID:foo@test
264 DTSTAMP:20111005T133225Z
265 DTSTART:20111005T133225Z
266 END:AVAILABLE
267 END:VAVAILABILITY
268 END:VCALENDAR
269 VCAL
270  ));
271 
272  // UID, DTSTAMP and DTSTART are missing.
274 <<<VCAL
275 BEGIN:VCALENDAR
276 VERSION:2.0
277 PRODID:-//id
278 BEGIN:VAVAILABILITY
279 UID:foo@test
280 DTSTAMP:20111005T133225Z
281 BEGIN:AVAILABLE
282 END:AVAILABLE
283 END:VAVAILABILITY
284 END:VCALENDAR
285 VCAL
286  ));
287 
288  // UID is missing.
290 <<<VCAL
291 BEGIN:VCALENDAR
292 VERSION:2.0
293 PRODID:-//id
294 BEGIN:VAVAILABILITY
295 UID:foo@test
296 DTSTAMP:20111005T133225Z
297 BEGIN:AVAILABLE
298 DTSTAMP:20111005T133225Z
299 DTSTART:20111005T133225Z
300 END:AVAILABLE
301 END:VAVAILABILITY
302 END:VCALENDAR
303 VCAL
304  ));
305 
306  // DTSTAMP is missing.
308 <<<VCAL
309 BEGIN:VCALENDAR
310 VERSION:2.0
311 PRODID:-//id
312 BEGIN:VAVAILABILITY
313 UID:foo@test
314 DTSTAMP:20111005T133225Z
315 BEGIN:AVAILABLE
316 UID:foo@test
317 DTSTART:20111005T133225Z
318 END:AVAILABLE
319 END:VAVAILABILITY
320 END:VCALENDAR
321 VCAL
322  ));
323 
324  // DTSTART is missing.
326 <<<VCAL
327 BEGIN:VCALENDAR
328 VERSION:2.0
329 PRODID:-//id
330 BEGIN:VAVAILABILITY
331 UID:foo@test
332 DTSTAMP:20111005T133225Z
333 BEGIN:AVAILABLE
334 UID:foo@test
335 DTSTAMP:20111005T133225Z
336 END:AVAILABLE
337 END:VAVAILABILITY
338 END:VCALENDAR
339 VCAL
340  ));
341 
342  }
assertIsNotValid(VObject\Document $document)
test()
Definition: build.php:107
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

◆ testRFCxxxSection3_2()

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

Definition at line 386 of file VAvailabilityTest.php.

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

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  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

◆ testVAvailabilityComponent()

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

Definition at line 17 of file VAvailabilityTest.php.

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

17  {
18 
19  $vcal = <<<VCAL
20 BEGIN:VCALENDAR
21 BEGIN:VAVAILABILITY
22 END:VAVAILABILITY
23 END:VCALENDAR
24 VCAL;
25  $document = Reader::read($vcal);
26 
27  $this->assertInstanceOf(__NAMESPACE__ . '\VAvailability', $document->VAVAILABILITY);
28 
29  }
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:

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