1<?php
2
3namespace Sabre\VObject;
4
5use
6    DateTime,
7    DateTimeZone;
8
9class Issue50Test extends \PHPUnit_Framework_TestCase {
10
11    function testExpand() {
12
13        $input = <<<ICS
14BEGIN:VCALENDAR
15VERSION:2.0
16PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
17BEGIN:VTIMEZONE
18TZID:Europe/Brussels
19X-LIC-LOCATION:Europe/Brussels
20BEGIN:DAYLIGHT
21TZOFFSETFROM:+0100
22TZOFFSETTO:+0200
23TZNAME:CEST
24DTSTART:19700329T020000
25RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
26END:DAYLIGHT
27BEGIN:STANDARD
28TZOFFSETFROM:+0200
29TZOFFSETTO:+0100
30TZNAME:CET
31DTSTART:19701025T030000
32RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
33END:STANDARD
34END:VTIMEZONE
35BEGIN:VEVENT
36CREATED:20130705T142510Z
37LAST-MODIFIED:20130715T132556Z
38DTSTAMP:20130715T132556Z
39UID:1aef0b27-3d92-4581-829a-11999dd36724
40SUMMARY:Werken
41RRULE:FREQ=DAILY;COUNT=5
42DTSTART;TZID=Europe/Brussels:20130715T090000
43DTEND;TZID=Europe/Brussels:20130715T170000
44LOCATION:Job
45DESCRIPTION:Vrij
46X-MOZ-GENERATION:9
47END:VEVENT
48BEGIN:VEVENT
49CREATED:20130715T081654Z
50LAST-MODIFIED:20130715T110931Z
51DTSTAMP:20130715T110931Z
52UID:1aef0b27-3d92-4581-829a-11999dd36724
53SUMMARY:Werken
54RECURRENCE-ID;TZID=Europe/Brussels:20130719T090000
55DTSTART;TZID=Europe/Brussels:20130719T070000
56DTEND;TZID=Europe/Brussels:20130719T150000
57SEQUENCE:1
58LOCATION:Job
59DESCRIPTION:Vrij
60X-MOZ-GENERATION:1
61END:VEVENT
62BEGIN:VEVENT
63CREATED:20130715T111654Z
64LAST-MODIFIED:20130715T132556Z
65DTSTAMP:20130715T132556Z
66UID:1aef0b27-3d92-4581-829a-11999dd36724
67SUMMARY:Werken
68RECURRENCE-ID;TZID=Europe/Brussels:20130716T090000
69DTSTART;TZID=Europe/Brussels:20130716T070000
70DTEND;TZID=Europe/Brussels:20130716T150000
71SEQUENCE:1
72LOCATION:Job
73X-MOZ-GENERATION:2
74END:VEVENT
75BEGIN:VEVENT
76CREATED:20130715T125942Z
77LAST-MODIFIED:20130715T130023Z
78DTSTAMP:20130715T130023Z
79UID:1aef0b27-3d92-4581-829a-11999dd36724
80SUMMARY:Werken
81RECURRENCE-ID;TZID=Europe/Brussels:20130717T090000
82DTSTART;TZID=Europe/Brussels:20130717T070000
83DTEND;TZID=Europe/Brussels:20130717T150000
84SEQUENCE:1
85LOCATION:Job
86X-MOZ-GENERATION:3
87END:VEVENT
88BEGIN:VEVENT
89CREATED:20130715T130024Z
90LAST-MODIFIED:20130715T130034Z
91DTSTAMP:20130715T130034Z
92UID:1aef0b27-3d92-4581-829a-11999dd36724
93SUMMARY:Werken
94RECURRENCE-ID;TZID=Europe/Brussels:20130718T090000
95DTSTART;TZID=Europe/Brussels:20130718T090000
96DTEND;TZID=Europe/Brussels:20130718T170000
97LOCATION:Job
98X-MOZ-GENERATION:5
99DESCRIPTION:Vrij
100END:VEVENT
101END:VCALENDAR
102ICS;
103
104        $vcal = Reader::read($input);
105        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
106
107        $it = new Recur\EventIterator($vcal, '1aef0b27-3d92-4581-829a-11999dd36724');
108
109        $result = array();
110        foreach($it as $instance) {
111
112            $result[] = $instance;
113
114        }
115
116        $tz = new DateTimeZone('Europe/Brussels');
117
118        $this->assertEquals(array(
119            new DateTime('2013-07-15 09:00:00', $tz),
120            new DateTime('2013-07-16 07:00:00', $tz),
121            new DateTime('2013-07-17 07:00:00', $tz),
122            new DateTime('2013-07-18 09:00:00', $tz),
123            new DateTime('2013-07-19 07:00:00', $tz),
124        ), $result);
125
126    }
127
128}
129