ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
VFreeBusyTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 use Sabre\VObject;
8 
9 class VFreeBusyTest extends TestCase {
10 
11  function testIsFree() {
12 
13  $input = <<<BLA
14 BEGIN:VCALENDAR
15 BEGIN:VFREEBUSY
16 FREEBUSY;FBTYPE=FREE:20120912T000500Z/PT1H
17 FREEBUSY;FBTYPE=BUSY:20120912T010000Z/20120912T020000Z
18 FREEBUSY;FBTYPE=BUSY-TENTATIVE:20120912T020000Z/20120912T030000Z
19 FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20120912T030000Z/20120912T040000Z
20 FREEBUSY;FBTYPE=BUSY:20120912T050000Z/20120912T060000Z,20120912T080000Z/20120912T090000Z
21 FREEBUSY;FBTYPE=BUSY:20120912T100000Z/PT1H
22 END:VFREEBUSY
23 END:VCALENDAR
24 BLA;
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
45 BEGIN:VCALENDAR
46 VERSION:2.0
47 PRODID:YoYo
48 BEGIN:VFREEBUSY
49 UID:some-random-id
50 DTSTAMP:20140402T180200Z
51 END:VFREEBUSY
52 END:VCALENDAR
53 HI;
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 }
if($argc< 3) $input
$messages
Definition: en.php:5
$warning
Definition: X509warning.php:13
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42