ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
VFreeBusyTest.php
Go to the documentation of this file.
1<?php
2
4
5use PHPUnit\Framework\TestCase;
8
9class VFreeBusyTest extends TestCase {
10
11 function testIsFree() {
12
13 $input = <<<BLA
14BEGIN:VCALENDAR
15BEGIN:VFREEBUSY
16FREEBUSY;FBTYPE=FREE:20120912T000500Z/PT1H
17FREEBUSY;FBTYPE=BUSY:20120912T010000Z/20120912T020000Z
18FREEBUSY;FBTYPE=BUSY-TENTATIVE:20120912T020000Z/20120912T030000Z
19FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20120912T030000Z/20120912T040000Z
20FREEBUSY;FBTYPE=BUSY:20120912T050000Z/20120912T060000Z,20120912T080000Z/20120912T090000Z
21FREEBUSY;FBTYPE=BUSY:20120912T100000Z/PT1H
22END:VFREEBUSY
23END:VCALENDAR
24BLA;
25
27 $vfb = $obj->VFREEBUSY;
28
29 $tz = new \DateTimeZone('UTC');
30
31 $this->assertFalse($vfb->isFree(new \DateTime('2012-09-12 01:15:00', $tz), new \DateTime('2012-09-12 01:45:00', $tz)));
32 $this->assertFalse($vfb->isFree(new \DateTime('2012-09-12 08:05:00', $tz), new \DateTime('2012-09-12 08:10:00', $tz)));
33 $this->assertFalse($vfb->isFree(new \DateTime('2012-09-12 10:15:00', $tz), new \DateTime('2012-09-12 10:45:00', $tz)));
34
35 // Checking whether the end time is treated as non-inclusive
36 $this->assertTrue($vfb->isFree(new \DateTime('2012-09-12 09:00:00', $tz), new \DateTime('2012-09-12 09:15:00', $tz)));
37 $this->assertTrue($vfb->isFree(new \DateTime('2012-09-12 09:45:00', $tz), new \DateTime('2012-09-12 10:00:00', $tz)));
38 $this->assertTrue($vfb->isFree(new \DateTime('2012-09-12 11:00:00', $tz), new \DateTime('2012-09-12 12:00:00', $tz)));
39
40 }
41
42 function testValidate() {
43
44 $input = <<<HI
45BEGIN:VCALENDAR
46VERSION:2.0
47PRODID:YoYo
48BEGIN:VFREEBUSY
49UID:some-random-id
50DTSTAMP:20140402T180200Z
51END:VFREEBUSY
52END:VCALENDAR
53HI;
54
55 $obj = Reader::read($input);
56
57 $warnings = $obj->validate();
58 $messages = [];
59 foreach ($warnings as $warning) {
60 $messages[] = $warning['message'];
61 }
62
63 $this->assertEquals([], $messages);
64
65 }
66
67}
$warning
Definition: X509warning.php:13
An exception for terminatinating execution or to throw for unit testing.
iCalendar/vCard/jCal/jCard/xCal/xCard reader object.
Definition: Reader.php:15
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
$messages
Definition: en.php:5
foreach($paths as $path) if($argc< 3) $input