comparison vendor/sabre/vobject/tests/VObject/Component/VFreeBusyTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
comparison
equal deleted inserted replaced
6:cec75ba50afc 7:430dbd5346f7
1 <?php
2
3 namespace Sabre\VObject\Component;
4
5 use Sabre\VObject;
6 use Sabre\VObject\Reader;
7
8 class VFreeBusyTest extends \PHPUnit_Framework_TestCase {
9
10 function testIsFree() {
11
12 $input = <<<BLA
13 BEGIN:VCALENDAR
14 BEGIN:VFREEBUSY
15 FREEBUSY;FBTYPE=FREE:20120912T000500Z/PT1H
16 FREEBUSY;FBTYPE=BUSY:20120912T010000Z/20120912T020000Z
17 FREEBUSY;FBTYPE=BUSY-TENTATIVE:20120912T020000Z/20120912T030000Z
18 FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20120912T030000Z/20120912T040000Z
19 FREEBUSY;FBTYPE=BUSY:20120912T050000Z/20120912T060000Z,20120912T080000Z/20120912T090000Z
20 FREEBUSY;FBTYPE=BUSY:20120912T100000Z/PT1H
21 END:VFREEBUSY
22 END:VCALENDAR
23 BLA;
24
25 $obj = VObject\Reader::read($input);
26 $vfb = $obj->VFREEBUSY;
27
28 $tz = new \DateTimeZone('UTC');
29
30 $this->assertFalse($vfb->isFree(new \DateTime('2012-09-12 01:15:00', $tz), new \DateTime('2012-09-12 01:45:00', $tz)));
31 $this->assertFalse($vfb->isFree(new \DateTime('2012-09-12 08:05:00', $tz), new \DateTime('2012-09-12 08:10:00', $tz)));
32 $this->assertFalse($vfb->isFree(new \DateTime('2012-09-12 10:15:00', $tz), new \DateTime('2012-09-12 10:45:00', $tz)));
33
34 // Checking whether the end time is treated as non-inclusive
35 $this->assertTrue($vfb->isFree(new \DateTime('2012-09-12 09:00:00', $tz), new \DateTime('2012-09-12 09:15:00', $tz)));
36 $this->assertTrue($vfb->isFree(new \DateTime('2012-09-12 09:45:00', $tz), new \DateTime('2012-09-12 10:00:00', $tz)));
37 $this->assertTrue($vfb->isFree(new \DateTime('2012-09-12 11:00:00', $tz), new \DateTime('2012-09-12 12:00:00', $tz)));
38
39 }
40
41 public function testValidate() {
42
43 $input = <<<HI
44 BEGIN:VCALENDAR
45 VERSION:2.0
46 PRODID:YoYo
47 BEGIN:VFREEBUSY
48 UID:some-random-id
49 DTSTAMP:20140402T180200Z
50 END:VFREEBUSY
51 END:VCALENDAR
52 HI;
53
54 $obj = Reader::read($input);
55
56 $warnings = $obj->validate();
57 $messages = array();
58 foreach($warnings as $warning) {
59 $messages[] = $warning['message'];
60 }
61
62 $this->assertEquals(array(), $messages);
63
64 }
65
66 }