annotate vendor/sabre/vobject/tests/VObject/Component/VFreeBusyTest.php @ 38:ac106d4c8961 default tip

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