1<?php 2 3namespace Sabre\VObject\Component; 4 5use DateTimeImmutable; 6use DateTimeZone; 7use Sabre\VObject\Reader; 8 9/** 10 * We use `RFCxxx` has a placeholder for the 11 * https://tools.ietf.org/html/draft-daboo-calendar-availability-05 name. 12 */ 13class AvailableTest extends \PHPUnit_Framework_TestCase { 14 15 function testAvailableComponent() { 16 17 $vcal = <<<VCAL 18BEGIN:VCALENDAR 19BEGIN:AVAILABLE 20END:AVAILABLE 21END:VCALENDAR 22VCAL; 23 $document = Reader::read($vcal); 24 $this->assertInstanceOf(__NAMESPACE__ . '\Available', $document->AVAILABLE); 25 26 } 27 28 function testGetEffectiveStartEnd() { 29 30 $vcal = <<<VCAL 31BEGIN:VCALENDAR 32BEGIN:AVAILABLE 33DTSTART:20150717T162200Z 34DTEND:20150717T172200Z 35END:AVAILABLE 36END:VCALENDAR 37VCAL; 38 39 $document = Reader::read($vcal); 40 $tz = new DateTimeZone('UTC'); 41 $this->assertEquals( 42 [ 43 new DateTimeImmutable('2015-07-17 16:22:00', $tz), 44 new DateTimeImmutable('2015-07-17 17:22:00', $tz), 45 ], 46 $document->AVAILABLE->getEffectiveStartEnd() 47 ); 48 49 } 50 51 function testGetEffectiveStartEndDuration() { 52 53 $vcal = <<<VCAL 54BEGIN:VCALENDAR 55BEGIN:AVAILABLE 56DTSTART:20150717T162200Z 57DURATION:PT1H 58END:AVAILABLE 59END:VCALENDAR 60VCAL; 61 62 $document = Reader::read($vcal); 63 $tz = new DateTimeZone('UTC'); 64 $this->assertEquals( 65 [ 66 new DateTimeImmutable('2015-07-17 16:22:00', $tz), 67 new DateTimeImmutable('2015-07-17 17:22:00', $tz), 68 ], 69 $document->AVAILABLE->getEffectiveStartEnd() 70 ); 71 72 } 73} 74