1<?php 2 3namespace Sabre\VObject; 4 5use 6 DateTime, 7 DateTimeZone; 8 9class ExpandFloatingTimesTest extends \PHPUnit_Framework_TestCase { 10 11 function testExpand() { 12 13 $input = <<<ICS 14BEGIN:VCALENDAR 15VERSION:2.0 16BEGIN:VEVENT 17UID:foo 18DTSTART:20150109T090000 19DTEND:20150109T100000 20RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20191002T070000Z;BYDAY=FR 21END:VEVENT 22END:VCALENDAR 23ICS; 24 25 $vcal = Reader::read($input); 26 $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); 27 28 $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-01-31')); 29 30 $result = $vcal->serialize(); 31 32 $output = <<<ICS 33BEGIN:VCALENDAR 34VERSION:2.0 35BEGIN:VEVENT 36UID:foo 37DTSTART:20150109T090000Z 38DTEND:20150109T100000Z 39END:VEVENT 40BEGIN:VEVENT 41UID:foo 42DTSTART:20150116T090000Z 43DTEND:20150116T100000Z 44RECURRENCE-ID:20150116T090000Z 45END:VEVENT 46BEGIN:VEVENT 47UID:foo 48DTSTART:20150123T090000Z 49DTEND:20150123T100000Z 50RECURRENCE-ID:20150123T090000Z 51END:VEVENT 52BEGIN:VEVENT 53UID:foo 54DTSTART:20150130T090000Z 55DTEND:20150130T100000Z 56RECURRENCE-ID:20150130T090000Z 57END:VEVENT 58END:VCALENDAR 59 60ICS; 61 $this->assertEquals($output, str_replace("\r", "", $result)); 62 63 } 64 65 function testExpandWithReferenceTimezone() { 66 67 $input = <<<ICS 68BEGIN:VCALENDAR 69VERSION:2.0 70BEGIN:VEVENT 71UID:foo 72DTSTART:20150109T090000 73DTEND:20150109T100000 74RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20191002T070000Z;BYDAY=FR 75END:VEVENT 76END:VCALENDAR 77ICS; 78 79 $vcal = Reader::read($input); 80 $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); 81 82 $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-01-31'), new \DateTimeZone('Europe/Berlin')); 83 84 $result = $vcal->serialize(); 85 86 $output = <<<ICS 87BEGIN:VCALENDAR 88VERSION:2.0 89BEGIN:VEVENT 90UID:foo 91DTSTART:20150109T080000Z 92DTEND:20150109T090000Z 93END:VEVENT 94BEGIN:VEVENT 95UID:foo 96DTSTART:20150116T080000Z 97DTEND:20150116T090000Z 98RECURRENCE-ID:20150116T080000Z 99END:VEVENT 100BEGIN:VEVENT 101UID:foo 102DTSTART:20150123T080000Z 103DTEND:20150123T090000Z 104RECURRENCE-ID:20150123T080000Z 105END:VEVENT 106BEGIN:VEVENT 107UID:foo 108DTSTART:20150130T080000Z 109DTEND:20150130T090000Z 110RECURRENCE-ID:20150130T080000Z 111END:VEVENT 112END:VCALENDAR 113 114ICS; 115 $this->assertEquals($output, str_replace("\r", "", $result)); 116 117 } 118 119} 120