annotate vendor/sabre/vobject/tests/VObject/Recur/EventIterator/MainTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
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\EventIterator;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 use DateTime;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6 use DateTimeZone;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7 use Sabre\VObject\Recur\EventIterator;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8 use Sabre\VObject\Component\VCalendar;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10 class MainTest extends \PHPUnit_Framework_TestCase {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 function testValues() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17 $ev->RRULE = 'FREQ=DAILY;BYHOUR=10;BYMINUTE=5;BYSECOND=16;BYWEEKNO=32;BYYEARDAY=100,200';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19 $dtStart->setDateTime(new DateTime('2011-10-07'));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27 $this->assertTrue($it->isInfinite());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
29 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
30
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
31 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
32 * @expectedException InvalidArgumentException
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35 function testInvalidFreq() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39 $ev->RRULE = 'FREQ=SMONTHLY;INTERVAL=3;UNTIL=20111025T000000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 $ev->UID = 'foo';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52 * @expectedException InvalidArgumentException
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54 function testVCalendarNoUID() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 $it = new EventIterator($vcal);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 }
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 * @expectedException InvalidArgumentException
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64 function testVCalendarInvalidUID() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67 $it = new EventIterator($vcal,'foo');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
70
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
71 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
72 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
73 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
74 function testHourly() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
75
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
76 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
77 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
78
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
79 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
80 $ev->RRULE = 'FREQ=HOURLY;INTERVAL=3;UNTIL=20111025T000000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
81 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
82 $dtStart->setDateTime(new DateTime('2011-10-07 12:00:00', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
83
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
84 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
85 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
86
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
87 $it = new EventIterator($vcal,$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
88
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
89 // Max is to prevent overflow
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
90 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
91 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
92 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
93
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
94 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
95 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
96
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
97 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
98
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
99 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
100
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
101 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
102
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
103 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
104 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
105 new DateTime('2011-10-07 12:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
106 new DateTime('2011-10-07 15:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
107 new DateTime('2011-10-07 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
108 new DateTime('2011-10-07 21:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
109 new DateTime('2011-10-08 00:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
110 new DateTime('2011-10-08 03:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
111 new DateTime('2011-10-08 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
112 new DateTime('2011-10-08 09:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
113 new DateTime('2011-10-08 12:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
114 new DateTime('2011-10-08 15:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
115 new DateTime('2011-10-08 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
116 new DateTime('2011-10-08 21:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
117 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
118 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
119 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
120
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
121 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
122
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
123 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
124 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
125 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
126 function testDaily() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
127
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
128 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
129 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
130
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
131 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
132 $ev->RRULE = 'FREQ=DAILY;INTERVAL=3;UNTIL=20111025T000000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
133 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
134 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
135
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
136 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
137
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
138 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
139
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
140 $it = new EventIterator($vcal,$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
141
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
142 // Max is to prevent overflow
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
143 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
144 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
145 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
146
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
147 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
148 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
149
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
150 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
151
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
152 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
153
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
154 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
155
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
156 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
157 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
158 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
159 new DateTime('2011-10-10', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
160 new DateTime('2011-10-13', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
161 new DateTime('2011-10-16', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
162 new DateTime('2011-10-19', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
163 new DateTime('2011-10-22', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
164 new DateTime('2011-10-25', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
165 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
166 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
167 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
168
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
169 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
170
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
171 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
172 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
173 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
174 function testNoRRULE() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
175
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
176 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
177 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
178
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
179 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
180 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
181 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
182
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
183 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
184
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
185 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
186
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
187 $it = new EventIterator($vcal,$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
188
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
189 // Max is to prevent overflow
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
190 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
191 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
192 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
193
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
194 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
195 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
196
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
197 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
198
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
199 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
200
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
201 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
203 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
204 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
205 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
206 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
207 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
208 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
209
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
210 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
211
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
212 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
213 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
214 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
215 function testDailyByDayByHour() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
216
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
217 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
218 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
219
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
220 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
221 $ev->RRULE = 'FREQ=DAILY;BYDAY=SA,SU;BYHOUR=6,7';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
222 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
223 $dtStart->setDateTime(new DateTime('2011-10-08 06:00:00', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
224
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
225 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
226
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
227 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
228
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
229 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
230
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
231 // Grabbing the next 12 items
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
232 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
233 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
234 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
235
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
236 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
237 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
238
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
239 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
240
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
241 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
242
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
243 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
244
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
245 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
246 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
247 new datetime('2011-10-08 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
248 new datetime('2011-10-08 07:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
249 new datetime('2011-10-09 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
250 new datetime('2011-10-09 07:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
251 new datetime('2011-10-15 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
252 new datetime('2011-10-15 07:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
253 new datetime('2011-10-16 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
254 new datetime('2011-10-16 07:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
255 new datetime('2011-10-22 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
256 new datetime('2011-10-22 07:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
257 new datetime('2011-10-23 06:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
258 new datetime('2011-10-23 07:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
259 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
260 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
261 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
262
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
263 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
264
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
265 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
266 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
267 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
268 function testDailyByHour() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
269
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
270 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
271 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
272
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
273 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
274 $ev->RRULE = 'FREQ=DAILY;INTERVAL=2;BYHOUR=10,11,12,13,14,15';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
275 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
276 $dtStart->setDateTime(new DateTime('2012-10-11 12:00:00', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
277
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
278 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
279
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
280 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
281
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
282 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
283
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
284 // Grabbing the next 12 items
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
285 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
286 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
287 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
288
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
289 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
290 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
291
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
292 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
293
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
294 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
295
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
296 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
297
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
298 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
299 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
300 new datetime('2012-10-11 12:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
301 new datetime('2012-10-11 13:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
302 new datetime('2012-10-11 14:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
303 new datetime('2012-10-11 15:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
304 new datetime('2012-10-13 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
305 new datetime('2012-10-13 11:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
306 new datetime('2012-10-13 12:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
307 new datetime('2012-10-13 13:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
308 new datetime('2012-10-13 14:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
309 new datetime('2012-10-13 15:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
310 new datetime('2012-10-15 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
311 new datetime('2012-10-15 11:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
312 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
313 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
314 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
315
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
316 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
317
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
318 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
319 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
320 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
321 function testDailyByDay() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
322
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
323 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
324 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
325
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
326 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
327 $ev->RRULE = 'FREQ=DAILY;INTERVAL=2;BYDAY=TU,WE,FR';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
328 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
329 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
330
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
331 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
332
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
333 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
334
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
335 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
336
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
337 // Grabbing the next 12 items
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
338 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
339 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
340 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
341
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
342 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
343 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
344
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
345 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
346
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
347 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
348
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
349 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
350
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
351 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
352 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
353 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
354 new DateTime('2011-10-11', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
355 new DateTime('2011-10-19', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
356 new DateTime('2011-10-21', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
357 new DateTime('2011-10-25', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
358 new DateTime('2011-11-02', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
359 new DateTime('2011-11-04', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
360 new DateTime('2011-11-08', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
361 new DateTime('2011-11-16', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
362 new DateTime('2011-11-18', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
363 new DateTime('2011-11-22', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
364 new DateTime('2011-11-30', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
365 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
366 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
367 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
368
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
369 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
370
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
371 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
372 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
373 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
374 function testWeekly() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
375
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
376 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
377 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
378
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
379 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
380 $ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;COUNT=10';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
381 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
382 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
383
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
384 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
385
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
386 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
387
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
388 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
389
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
390 // Max is to prevent overflow
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
391 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
392 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
393 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
394
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
395 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
396 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
397
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
398 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
399
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
400 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
401
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
402 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
403
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
404 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
405 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
406 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
407 new DateTime('2011-10-21', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
408 new DateTime('2011-11-04', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
409 new DateTime('2011-11-18', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
410 new DateTime('2011-12-02', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
411 new DateTime('2011-12-16', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
412 new DateTime('2011-12-30', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
413 new DateTime('2012-01-13', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
414 new DateTime('2012-01-27', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
415 new DateTime('2012-02-10', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
416 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
417 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
418 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
419
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
420 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
421
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
422 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
423 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
424 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
425 function testWeeklyByDayByHour() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
426
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
427 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
428 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
429
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
430 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
431 $ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR;WKST=MO;BYHOUR=8,9,10';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
432 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
433 $dtStart->setDateTime(new DateTime('2011-10-07 08:00:00', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
434
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
435 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
436
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
437 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
438
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
439 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
440
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
441 // Grabbing the next 12 items
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
442 $max = 15;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
443 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
444 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
445
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
446 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
447 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
448
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
449 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
450
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
451 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
452
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
453 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
454
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
455 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
456 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
457 new DateTime('2011-10-07 08:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
458 new DateTime('2011-10-07 09:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
459 new DateTime('2011-10-07 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
460 new DateTime('2011-10-18 08:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
461 new DateTime('2011-10-18 09:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
462 new DateTime('2011-10-18 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
463 new DateTime('2011-10-19 08:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
464 new DateTime('2011-10-19 09:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
465 new DateTime('2011-10-19 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
466 new DateTime('2011-10-21 08:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
467 new DateTime('2011-10-21 09:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
468 new DateTime('2011-10-21 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
469 new DateTime('2011-11-01 08:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
470 new DateTime('2011-11-01 09:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
471 new DateTime('2011-11-01 10:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
472 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
473 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
474 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
475
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
476 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
477
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
478 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
479 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
480 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
481 function testWeeklyByDaySpecificHour() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
482
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
483 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
484 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
485
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
486 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
487 $ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR;WKST=SU';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
488 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
489 $dtStart->setDateTime(new DateTime('2011-10-07 18:00:00', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
490
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
491 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
492
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
493 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
494
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
495 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
496
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
497 // Grabbing the next 12 items
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
498 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
499 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
500 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
501
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
502 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
503 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
504
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
505 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
506
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
507 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
508
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
509 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
510
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
511 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
512 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
513 new DateTime('2011-10-07 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
514 new DateTime('2011-10-18 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
515 new DateTime('2011-10-19 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
516 new DateTime('2011-10-21 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
517 new DateTime('2011-11-01 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
518 new DateTime('2011-11-02 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
519 new DateTime('2011-11-04 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
520 new DateTime('2011-11-15 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
521 new DateTime('2011-11-16 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
522 new DateTime('2011-11-18 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
523 new DateTime('2011-11-29 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
524 new DateTime('2011-11-30 18:00:00', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
525 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
526 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
527 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
528
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
529 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
530
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
531 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
532 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
533 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
534 function testWeeklyByDay() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
535
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
536 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
537 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
538
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
539 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
540 $ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR;WKST=SU';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
541 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
542 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
543
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
544 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
545
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
546 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
547
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
548 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
549
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
550 // Grabbing the next 12 items
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
551 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
552 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
553 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
554
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
555 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
556 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
557
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
558 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
559
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
560 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
561
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
562 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
563
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
564 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
565 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
566 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
567 new DateTime('2011-10-18', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
568 new DateTime('2011-10-19', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
569 new DateTime('2011-10-21', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
570 new DateTime('2011-11-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
571 new DateTime('2011-11-02', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
572 new DateTime('2011-11-04', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
573 new DateTime('2011-11-15', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
574 new DateTime('2011-11-16', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
575 new DateTime('2011-11-18', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
576 new DateTime('2011-11-29', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
577 new DateTime('2011-11-30', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
578 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
579 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
580 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
581
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
582 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
583
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
584 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
585 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
586 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
587 function testMonthly() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
588
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
589 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
590 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
591
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
592 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
593 $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=3;COUNT=5';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
594 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
595 $dtStart->setDateTime(new DateTime('2011-12-05', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
596
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
597 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
598
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
599 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
600
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
601 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
602
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
603 $max = 14;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
604 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
605 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
606
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
607 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
608 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
609
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
610 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
611
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
612 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
613
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
614 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
615
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
616 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
617 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
618 new DateTime('2011-12-05', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
619 new DateTime('2012-03-05', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
620 new DateTime('2012-06-05', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
621 new DateTime('2012-09-05', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
622 new DateTime('2012-12-05', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
623 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
624 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
625 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
626
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
627
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
628 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
629
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
630 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
631 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
632 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
633 function testMonthlyEndOfMonth() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
634
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
635 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
636 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
637
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
638 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
639 $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=2;COUNT=12';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
640 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
641 $dtStart->setDateTime(new DateTime('2011-12-31', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
642
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
643 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
644
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
645 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
646
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
647 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
648
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
649 $max = 14;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
650 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
651 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
652
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
653 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
654 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
655
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
656 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
657
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
658 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
659
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
660 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
661
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
662 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
663 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
664 new DateTime('2011-12-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
665 new DateTime('2012-08-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
666 new DateTime('2012-10-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
667 new DateTime('2012-12-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
668 new DateTime('2013-08-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
669 new DateTime('2013-10-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
670 new DateTime('2013-12-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
671 new DateTime('2014-08-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
672 new DateTime('2014-10-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
673 new DateTime('2014-12-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
674 new DateTime('2015-08-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
675 new DateTime('2015-10-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
676 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
677 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
678 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
679
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
680
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
681 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
682
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
683 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
684 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
685 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
686 function testMonthlyByMonthDay() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
687
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
688 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
689 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
690
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
691 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
692 $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=5;COUNT=9;BYMONTHDAY=1,31,-7';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
693 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
694 $dtStart->setDateTime(new DateTime('2011-01-01', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
695
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
696 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
697
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
698 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
699
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
700 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
701
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
702 $max = 14;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
703 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
704 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
705
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
706 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
707 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
708
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
709 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
710
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
711 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
712
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
713 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
714
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
715 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
716 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
717 new DateTime('2011-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
718 new DateTime('2011-01-25', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
719 new DateTime('2011-01-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
720 new DateTime('2011-06-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
721 new DateTime('2011-06-24', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
722 new DateTime('2011-11-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
723 new DateTime('2011-11-24', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
724 new DateTime('2012-04-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
725 new DateTime('2012-04-24', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
726 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
727 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
728 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
729
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
730 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
731
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
732 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
733 * A pretty slow test. Had to be marked as 'medium' for phpunit to not die
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
734 * after 1 second. Would be good to optimize later.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
735 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
736 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
737 * @medium
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
738 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
739 function testMonthlyByDay() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
740
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
741 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
742 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
743
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
744 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
745 $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=2;COUNT=16;BYDAY=MO,-2TU,+1WE,3TH';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
746 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
747 $dtStart->setDateTime(new DateTime('2011-01-03', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
748
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
749 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
750
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
751 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
752
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
753 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
754
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
755 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
756 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
757 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
758
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
759 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
760 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
761
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
762 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
763
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
764 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
765
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
766 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
767
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
768 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
769 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
770 new DateTime('2011-01-03', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
771 new DateTime('2011-01-05', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
772 new DateTime('2011-01-10', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
773 new DateTime('2011-01-17', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
774 new DateTime('2011-01-18', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
775 new DateTime('2011-01-20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
776 new DateTime('2011-01-24', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
777 new DateTime('2011-01-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
778 new DateTime('2011-03-02', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
779 new DateTime('2011-03-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
780 new DateTime('2011-03-14', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
781 new DateTime('2011-03-17', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
782 new DateTime('2011-03-21', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
783 new DateTime('2011-03-22', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
784 new DateTime('2011-03-28', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
785 new DateTime('2011-05-02', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
786 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
787 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
788 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
789
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
790 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
791
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
792 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
793 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
794 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
795 function testMonthlyByDayByMonthDay() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
796
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
797 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
798 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
799
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
800 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
801 $ev->RRULE = 'FREQ=MONTHLY;COUNT=10;BYDAY=MO;BYMONTHDAY=1';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
802 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
803 $dtStart->setDateTime(new DateTime('2011-08-01', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
804
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
805 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
806
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
807 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
808
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
809 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
810
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
811 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
812 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
813 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
814
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
815 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
816 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
817
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
818 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
819
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
820 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
821
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
822 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
823
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
824 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
825 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
826 new DateTime('2011-08-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
827 new DateTime('2012-10-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
828 new DateTime('2013-04-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
829 new DateTime('2013-07-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
830 new DateTime('2014-09-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
831 new DateTime('2014-12-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
832 new DateTime('2015-06-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
833 new DateTime('2016-02-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
834 new DateTime('2016-08-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
835 new DateTime('2017-05-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
836 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
837 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
838 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
839
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
840 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
841
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
842 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
843 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
844 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
845 function testMonthlyByDayBySetPos() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
846
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
847 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
848 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
849
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
850 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
851 $ev->RRULE = 'FREQ=MONTHLY;COUNT=10;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1,-1';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
852 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
853 $dtStart->setDateTime(new DateTime('2011-01-03', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
854
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
855 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
856
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
857 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
858
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
859 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
860
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
861 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
862 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
863 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
864
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
865 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
866 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
867
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
868 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
869
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
870 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
871
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
872 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
873
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
874 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
875 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
876 new DateTime('2011-01-03', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
877 new DateTime('2011-01-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
878 new DateTime('2011-02-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
879 new DateTime('2011-02-28', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
880 new DateTime('2011-03-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
881 new DateTime('2011-03-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
882 new DateTime('2011-04-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
883 new DateTime('2011-04-29', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
884 new DateTime('2011-05-02', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
885 new DateTime('2011-05-31', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
886 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
887 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
888 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
889
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
890 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
891
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
892 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
893 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
894 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
895 function testYearly() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
896
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
897 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
898 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
899
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
900 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
901 $ev->RRULE = 'FREQ=YEARLY;COUNT=10;INTERVAL=3';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
902 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
903 $dtStart->setDateTime(new DateTime('2011-01-01', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
904
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
905 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
906
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
907 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
908
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
909 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
910
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
911 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
912 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
913 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
914
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
915 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
916 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
917
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
918 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
919
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
920 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
921
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
922 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
923
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
924 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
925 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
926 new DateTime('2011-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
927 new DateTime('2014-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
928 new DateTime('2017-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
929 new DateTime('2020-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
930 new DateTime('2023-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
931 new DateTime('2026-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
932 new DateTime('2029-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
933 new DateTime('2032-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
934 new DateTime('2035-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
935 new DateTime('2038-01-01', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
936 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
937 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
938 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
939
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
940 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
941
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
942 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
943 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
944 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
945 function testYearlyLeapYear() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
946
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
947 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
948 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
949
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
950 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
951 $ev->RRULE = 'FREQ=YEARLY;COUNT=3';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
952 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
953 $dtStart->setDateTime(new DateTime('2012-02-29', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
954
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
955 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
956
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
957 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
958
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
959 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
960
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
961 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
962 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
963 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
964
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
965 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
966 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
967
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
968 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
969
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
970 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
971
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
972 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
973
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
974 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
975 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
976 new DateTime('2012-02-29', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
977 new DateTime('2016-02-29', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
978 new DateTime('2020-02-29', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
979 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
980 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
981 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
982
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
983 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
984
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
985 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
986 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
987 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
988 function testYearlyByMonth() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
989
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
990 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
991 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
992
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
993 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
994 $ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=4;BYMONTH=4,10';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
995 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
996 $dtStart->setDateTime(new DateTime('2011-04-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
997
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
998 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
999
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1000 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1001
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1002 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1003
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1004 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1005 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1006 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1007
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1008 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1009 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1010
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1011 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1012
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1013 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1014
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1015 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1016
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1017 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1018 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1019 new DateTime('2011-04-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1020 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1021 new DateTime('2015-04-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1022 new DateTime('2015-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1023 new DateTime('2019-04-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1024 new DateTime('2019-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1025 new DateTime('2023-04-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1026 new DateTime('2023-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1027 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1028 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1029 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1030
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1031 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1032
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1033 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1034 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1035 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1036 function testYearlyByMonthByDay() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1037
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1038 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1039 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1040
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1041 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1042 $ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=5;BYMONTH=4,10;BYDAY=1MO,-1SU';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1043 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1044 $dtStart->setDateTime(new DateTime('2011-04-04', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1045
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1046 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1047
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1048 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1049
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1050 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1051
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1052 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1053 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1054 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1055
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1056 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1057 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1058
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1059 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1060
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1061 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1062
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1063 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1064
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1065 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1066 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1067 new DateTime('2011-04-04', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1068 new DateTime('2011-04-24', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1069 new DateTime('2011-10-03', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1070 new DateTime('2011-10-30', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1071 new DateTime('2016-04-04', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1072 new DateTime('2016-04-24', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1073 new DateTime('2016-10-03', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1074 new DateTime('2016-10-30', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1075 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1076 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1077 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1078
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1079 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1080
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1081 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1082 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1083 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1084 function testFastForward() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1085
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1086 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1087 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1088
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1089 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1090 $ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=5;BYMONTH=4,10;BYDAY=1MO,-1SU';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1091 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1092 $dtStart->setDateTime(new DateTime('2011-04-04', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1093
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1094 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1095
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1096 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1097
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1098 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1099
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1100 // The idea is that we're fast-forwarding too far in the future, so
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1101 // there will be no results left.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1102 $it->fastForward(new DateTime('2020-05-05', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1103
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1104 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1105 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1106 while($item = $it->current()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1107
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1108 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1109 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1110
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1111 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1112 $it->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1113
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1114 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1115
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1116 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1117 $this->assertEquals(array(), $result);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1118
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1119 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1120
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1121 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1122 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1123 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1124 function testComplexExclusions() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1125
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1126 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1127 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1128
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1129 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1130 $ev->RRULE = 'FREQ=YEARLY;COUNT=10';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1131 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1132
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1133 $tz = new DateTimeZone('Canada/Eastern');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1134 $dtStart->setDateTime(new DateTime('2011-01-01 13:50:20', $tz));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1135
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1136 $exDate1 = $vcal->createProperty('EXDATE');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1137 $exDate1->setDateTimes(array(new DateTime('2012-01-01 13:50:20', $tz), new DateTime('2014-01-01 13:50:20', $tz)));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1138 $exDate2 = $vcal->createProperty('EXDATE');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1139 $exDate2->setDateTimes(array(new DateTime('2016-01-01 13:50:20', $tz)));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1140
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1141 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1142 $ev->add($exDate1);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1143 $ev->add($exDate2);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1144
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1145 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1146
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1147 $it = new EventIterator($vcal,(string)$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1148
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1149 $max = 20;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1150 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1151 foreach($it as $k=>$item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1152
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1153 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1154 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1155
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1156 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1157
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1158 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1159
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1160 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1161 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1162 new DateTime('2011-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1163 new DateTime('2013-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1164 new DateTime('2015-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1165 new DateTime('2017-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1166 new DateTime('2018-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1167 new DateTime('2019-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1168 new DateTime('2020-01-01 13:50:20', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1169 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1170 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1171 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1172
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1173 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1174
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1175 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1176 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1177 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1178 function testOverridenEvent() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1179
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1180 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1181
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1182 $ev1 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1183 $ev1->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1184 $ev1->RRULE = 'FREQ=DAILY;COUNT=10';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1185 $ev1->DTSTART = '20120107T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1186 $ev1->SUMMARY = 'baseEvent';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1187
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1188 $vcal->add($ev1);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1189
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1190 // ev2 overrides an event, and puts it on 2pm instead.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1191 $ev2 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1192 $ev2->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1193 $ev2->{'RECURRENCE-ID'} = '20120110T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1194 $ev2->DTSTART = '20120110T140000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1195 $ev2->SUMMARY = 'Event 2';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1196
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1197 $vcal->add($ev2);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1198
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1199 // ev3 overrides an event, and puts it 2 days and 2 hours later
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1200 $ev3 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1201 $ev3->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1202 $ev3->{'RECURRENCE-ID'} = '20120113T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1203 $ev3->DTSTART = '20120115T140000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1204 $ev3->SUMMARY = 'Event 3';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1205
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1206 $vcal->add($ev3);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1207
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1208 $it = new EventIterator($vcal,'overridden');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1209
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1210 $dates = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1211 $summaries = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1212 while($it->valid()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1213
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1214 $dates[] = $it->getDTStart();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1215 $summaries[] = (string)$it->getEventObject()->SUMMARY;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1216 $it->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1217
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1218 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1219
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1220 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1221 $this->assertEquals(array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1222 new DateTime('2012-01-07 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1223 new DateTime('2012-01-08 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1224 new DateTime('2012-01-09 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1225 new DateTime('2012-01-10 14:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1226 new DateTime('2012-01-11 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1227 new DateTime('2012-01-12 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1228 new DateTime('2012-01-14 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1229 new DateTime('2012-01-15 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1230 new DateTime('2012-01-15 14:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1231 new DateTime('2012-01-16 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1232 ), $dates);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1233
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1234 $this->assertEquals(array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1235 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1236 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1237 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1238 'Event 2',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1239 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1240 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1241 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1242 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1243 'Event 3',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1244 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1245 ), $summaries);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1246
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1247 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1248
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1249 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1250 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1251 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1252 function testOverridenEvent2() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1253
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1254 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1255
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1256 $ev1 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1257 $ev1->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1258 $ev1->RRULE = 'FREQ=WEEKLY;COUNT=3';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1259 $ev1->DTSTART = '20120112T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1260 $ev1->SUMMARY = 'baseEvent';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1261
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1262 $vcal->add($ev1);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1263
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1264 // ev2 overrides an event, and puts it 6 days earlier instead.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1265 $ev2 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1266 $ev2->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1267 $ev2->{'RECURRENCE-ID'} = '20120119T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1268 $ev2->DTSTART = '20120113T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1269 $ev2->SUMMARY = 'Override!';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1270
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1271 $vcal->add($ev2);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1272
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1273 $it = new EventIterator($vcal,'overridden');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1274
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1275 $dates = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1276 $summaries = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1277 while($it->valid()) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1278
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1279 $dates[] = $it->getDTStart();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1280 $summaries[] = (string)$it->getEventObject()->SUMMARY;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1281 $it->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1282
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1283 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1284
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1285 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1286 $this->assertEquals(array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1287 new DateTime('2012-01-12 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1288 new DateTime('2012-01-13 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1289 new DateTime('2012-01-26 12:00:00',$tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1290
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1291 ), $dates);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1292
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1293 $this->assertEquals(array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1294 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1295 'Override!',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1296 'baseEvent',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1297 ), $summaries);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1298
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1299 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1300
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1301 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1302 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1303 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1304 function testOverridenEventNoValuesExpected() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1305
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1306 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1307 $ev1 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1308
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1309 $ev1->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1310 $ev1->RRULE = 'FREQ=WEEKLY;COUNT=3';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1311 $ev1->DTSTART = '20120124T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1312 $ev1->SUMMARY = 'baseEvent';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1313
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1314 $vcal->add($ev1);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1315
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1316 // ev2 overrides an event, and puts it 6 days earlier instead.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1317 $ev2 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1318 $ev2->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1319 $ev2->{'RECURRENCE-ID'} = '20120131T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1320 $ev2->DTSTART = '20120125T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1321 $ev2->SUMMARY = 'Override!';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1322
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1323 $vcal->add($ev2);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1324
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1325 $it = new EventIterator($vcal,'overridden');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1326
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1327 $dates = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1328 $summaries = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1329
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1330 // The reported problem was specifically related to the VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1331 // expansion. In this parcitular case, we had to forward to the 28th of
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1332 // january.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1333 $it->fastForward(new DateTime('2012-01-28 23:00:00'));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1334
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1335 // We stop the loop when it hits the 6th of februari. Normally this
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1336 // iterator would hit 24, 25 (overriden from 31) and 7 feb but because
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1337 // we 'filter' from the 28th till the 6th, we should get 0 results.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1338 while($it->valid() && $it->getDTSTart() < new DateTime('2012-02-06 23:00:00')) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1339
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1340 $dates[] = $it->getDTStart();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1341 $summaries[] = (string)$it->getEventObject()->SUMMARY;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1342 $it->next();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1343
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1344 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1345
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1346 $this->assertEquals(array(), $dates);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1347 $this->assertEquals(array(), $summaries);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1348
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1349 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1350
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1351 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1352 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1353 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1354 function testRDATE() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1355
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1356 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1357 $ev = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1358
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1359 $ev->UID = 'bla';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1360 $ev->RDATE = array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1361 new DateTime('2014-08-07', new DateTimeZone('UTC')),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1362 new DateTime('2014-08-08', new DateTimeZone('UTC')),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1363 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1364 $dtStart = $vcal->createProperty('DTSTART');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1365 $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1366
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1367 $ev->add($dtStart);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1368
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1369 $vcal->add($ev);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1370
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1371 $it = new EventIterator($vcal,$ev->uid);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1372
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1373 // Max is to prevent overflow
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1374 $max = 12;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1375 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1376 foreach($it as $item) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1377
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1378 $result[] = $item;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1379 $max--;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1380
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1381 if (!$max) break;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1382
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1383 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1384
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1385 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1386
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1387 $this->assertEquals(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1388 array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1389 new DateTime('2011-10-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1390 new DateTime('2014-08-07', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1391 new DateTime('2014-08-08', $tz),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1392 ),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1393 $result
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1394 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1395
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1396 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1397
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1398 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1399 * @depends testValues
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1400 * @expectedException \InvalidArgumentException
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1401 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1402 function testNoMasterBadUID() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1403
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1404 $vcal = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1405 // ev2 overrides an event, and puts it on 2pm instead.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1406 $ev2 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1407 $ev2->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1408 $ev2->{'RECURRENCE-ID'} = '20120110T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1409 $ev2->DTSTART = '20120110T140000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1410 $ev2->SUMMARY = 'Event 2';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1411
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1412 $vcal->add($ev2);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1413
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1414 // ev3 overrides an event, and puts it 2 days and 2 hours later
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1415 $ev3 = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1416 $ev3->UID = 'overridden';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1417 $ev3->{'RECURRENCE-ID'} = '20120113T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1418 $ev3->DTSTART = '20120115T140000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1419 $ev3->SUMMARY = 'Event 3';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1420
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1421 $vcal->add($ev3);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1422
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1423 $it = new EventIterator($vcal,'broken');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1424
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1425 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1426 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1427