annotate vendor/sabre/vobject/tests/VObject/Component/VCalendarTest.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\Component;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 use DateTimeZone;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6 use Sabre\VObject;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8 class VCalendarTest extends \PHPUnit_Framework_TestCase {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11 * @dataProvider expandData
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13 public function testExpand($input, $output, $timeZone = 'UTC', $start = '2011-12-01', $end = '2011-12-31') {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17 $timeZone = new DateTimeZone($timeZone);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19 $vcal->expand(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20 new \DateTime($start),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21 new \DateTime($end),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22 $timeZone
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 // This will normalize the output
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26 $output = VObject\Reader::read($output)->serialize();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28 $this->assertEquals($output, $vcal->serialize());
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 public function expandData() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34 $tests = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36 // No data
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43 $output = $input;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44 $tests[] = array($input,$output);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47 // Simple events
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52 UID:bla
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53 SUMMARY:InExpand
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 UID:bla2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58 SUMMARY:NotInExpand
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 DTSTART;VALUE=DATE:20120101
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
60 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
61 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
62 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64 $output = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68 UID:bla
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69 SUMMARY:InExpand
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
70 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
71 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
72 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
73 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
74
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
75 $tests[] = array($input, $output);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
76
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
77 // Removing timezone info
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
78 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
79 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
80 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
81 BEGIN:VTIMEZONE
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
82 TZID:Europe/Paris
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
83 END:VTIMEZONE
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
84 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
85 UID:bla4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
86 SUMMARY:RemoveTZ info
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
87 DTSTART;TZID=Europe/Paris:20111203T130102
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
88 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
89 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
90 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
91
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
92 $output = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
93 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
94 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
95 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
96 UID:bla4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
97 SUMMARY:RemoveTZ info
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
98 DTSTART:20111203T120102Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
99 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
100 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
101 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
102
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
103 $tests[] = array($input, $output);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
104
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
105 // Recurrence rule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
106 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
107 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
108 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
109 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
110 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
111 SUMMARY:Testing RRule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
112 DTSTART:20111125T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
113 DTEND:20111125T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
114 RRULE:FREQ=WEEKLY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
115 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
116 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
117 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
118
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
119 $output = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
120 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
121 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
122 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
123 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
124 SUMMARY:Testing RRule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
125 DTSTART:20111202T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
126 DTEND:20111202T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
127 RECURRENCE-ID:20111202T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
128 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
129 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
130 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
131 SUMMARY:Testing RRule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
132 DTSTART:20111209T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
133 DTEND:20111209T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
134 RECURRENCE-ID:20111209T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
135 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
136 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
137 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
138 SUMMARY:Testing RRule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
139 DTSTART:20111216T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
140 DTEND:20111216T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
141 RECURRENCE-ID:20111216T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
142 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
143 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
144 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
145 SUMMARY:Testing RRule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
146 DTSTART:20111223T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
147 DTEND:20111223T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
148 RECURRENCE-ID:20111223T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
149 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
150 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
151 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
152 SUMMARY:Testing RRule
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
153 DTSTART:20111230T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
154 DTEND:20111230T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
155 RECURRENCE-ID:20111230T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
156 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
157 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
158 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
159
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
160 $tests[] = array($input, $output);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
161
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
162 // Recurrence rule + override
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
163 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
164 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
165 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
166 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
167 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
168 SUMMARY:Testing RRule2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
169 DTSTART:20111125T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
170 DTEND:20111125T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
171 RRULE:FREQ=WEEKLY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
172 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
173 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
174 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
175 RECURRENCE-ID:20111209T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
176 DTSTART:20111209T140000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
177 DTEND:20111209T150000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
178 SUMMARY:Override!
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
179 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
180 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
181 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
182
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
183 $output = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
184 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
185 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
186 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
187 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
188 SUMMARY:Testing RRule2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
189 DTSTART:20111202T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
190 DTEND:20111202T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
191 RECURRENCE-ID:20111202T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
192 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
193 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
194 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
195 RECURRENCE-ID:20111209T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
196 DTSTART:20111209T140000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
197 DTEND:20111209T150000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
198 SUMMARY:Override!
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
199 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
200 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
201 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
202 SUMMARY:Testing RRule2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
203 DTSTART:20111216T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
204 DTEND:20111216T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
205 RECURRENCE-ID:20111216T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
206 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
207 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
208 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
209 SUMMARY:Testing RRule2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
210 DTSTART:20111223T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
211 DTEND:20111223T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
212 RECURRENCE-ID:20111223T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
213 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
214 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
215 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
216 SUMMARY:Testing RRule2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
217 DTSTART:20111230T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
218 DTEND:20111230T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
219 RECURRENCE-ID:20111230T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
220 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
221 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
222 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
223
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
224 $tests[] = array($input, $output);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
225
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
226 // Floating dates and times.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
227 $input = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
228 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
229 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
230 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
231 UID:bla1
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
232 DTSTART:20141112T195000
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
233 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
234 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
235 UID:bla2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
236 DTSTART;VALUE=DATE:20141112
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
237 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
238 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
239 UID:bla3
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
240 DTSTART;VALUE=DATE:20141112
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
241 RRULE:FREQ=DAILY;COUNT=2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
242 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
243 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
244 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
245
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
246 $output = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
247 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
248 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
249 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
250 UID:bla1
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
251 DTSTART:20141112T225000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
252 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
253 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
254 UID:bla2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
255 DTSTART;VALUE=DATE:20141112
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
256 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
257 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
258 UID:bla3
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
259 DTSTART;VALUE=DATE:20141112
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
260 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
261 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
262 UID:bla3
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
263 DTSTART;VALUE=DATE:20141113
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
264 RECURRENCE-ID;VALUE=DATE:20141113
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
265 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
266 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
267 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
268
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
269 $tests[] = array($input, $output, 'America/Argentina/Buenos_Aires', '2014-01-01', '2015-01-01');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
270
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
271 // Recurrence rule with no valid instances
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
272 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
273 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
274 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
275 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
276 UID:bla6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
277 SUMMARY:Testing RRule3
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
278 DTSTART:20111125T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
279 DTEND:20111125T130000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
280 RRULE:FREQ=WEEKLY;COUNT=1
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
281 EXDATE:20111125T120000Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
282 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
283 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
284 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
285
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
286 $output = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
287 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
288 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
289 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
290 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
291
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
292 $tests[] = array($input, $output);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
293 return $tests;
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
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
297 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
298 * @expectedException LogicException
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
299 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
300 public function testBrokenEventExpand() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
301
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
302 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
303 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
304 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
305 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
306 RRULE:FREQ=WEEKLY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
307 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
308 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
309 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
310 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
311 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
312 $vcal->expand(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
313 new \DateTime('2011-12-01'),
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
314 new \DateTime('2011-12-31')
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 function testGetDocumentType() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
320
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
321 $vcard = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
322 $vcard->VERSION = '2.0';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
323 $this->assertEquals(VCalendar::ICALENDAR20, $vcard->getDocumentType());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
324
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
325 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
326
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
327 function testValidateCorrect() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
328
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
329 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
330 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
331 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
332 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
333 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
334 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
335 DTSTAMP:20140122T233226Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
336 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
337 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
338 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
339 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
340
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
341 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
342 $this->assertEquals(array(), $vcal->validate(), 'Got an error');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
343
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
344 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
345
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
346 function testValidateNoVersion() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
347
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
348 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
349 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
350 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
351 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
352 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
353 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
354 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
355 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
356 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
357 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
358
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
359 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
360 $this->assertEquals(1, count($vcal->validate()));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
361
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
362 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
363
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
364 function testValidateWrongVersion() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
365
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
366 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
367 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
368 VERSION:3.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
369 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
370 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
371 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
372 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
373 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
374 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
375 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
376 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
377
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
378 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
379 $this->assertEquals(1, count($vcal->validate()));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
380
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
381 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
382
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
383 function testValidateNoProdId() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
384
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
385 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
386 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
387 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
388 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
389 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
390 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
391 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
392 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
393 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
394 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
395
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
396 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
397 $this->assertEquals(1, count($vcal->validate()));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
398
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 function testValidateDoubleCalScale() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
402
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
403 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
404 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
405 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
406 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
407 CALSCALE:GREGORIAN
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
408 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
409 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
410 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
411 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
412 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
413 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
414 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
415
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
416 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
417 $this->assertEquals(1, count($vcal->validate()));
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 function testValidateDoubleMethod() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
422
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
423 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
424 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
425 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
426 METHOD:REQUEST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
427 METHOD:REQUEST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
428 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
429 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
430 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
431 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
432 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
433 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
434 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
435
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
436 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
437 $this->assertEquals(1, count($vcal->validate()));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
438
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
439 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
440
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
441 function testValidateTwoMasterEvents() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
442
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
443 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
444 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
445 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
446 METHOD:REQUEST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
447 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
448 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
449 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
450 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
451 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
452 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
453 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
454 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
455 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
456 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
457 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
458 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
459
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
460 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
461 $this->assertEquals(1, count($vcal->validate()));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
462
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
463 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
464
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
465 function testValidateOneMasterEvent() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
466
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
467 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
468 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
469 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
470 METHOD:REQUEST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
471 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
472 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
473 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
474 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
475 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
476 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
477 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
478 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
479 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
480 RECURRENCE-ID;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
481 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
482 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
483 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
484
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
485 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
486 $this->assertEquals(0, count($vcal->validate()));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
487
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
488 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
489
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
490 function testGetBaseComponent() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
491
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
492 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
493 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
494 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
495 METHOD:REQUEST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
496 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
497 SUMMARY:test
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
498 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
499 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
500 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
501 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
502 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
503 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
504 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
505 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
506 RECURRENCE-ID;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
507 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
508 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
509 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
510
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
511 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
512
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
513 $result = $vcal->getBaseComponent();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
514 $this->assertEquals('test', $result->SUMMARY->getValue());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
515
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
516 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
517
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
518 function testGetBaseComponentNoResult() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
519
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
520 $input = 'BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
521 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
522 PRODID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
523 METHOD:REQUEST
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
524 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
525 SUMMARY:test
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
526 RECURRENCE-ID;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
527 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
528 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
529 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
530 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
531 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
532 DTSTART;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
533 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
534 DTSTAMP:20140122T234434Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
535 RECURRENCE-ID;VALUE=DATE:20111202
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
536 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
537 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
538 ';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
539
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
540 $vcal = VObject\Reader::read($input);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
541
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
542 $result = $vcal->getBaseComponent();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
543 $this->assertNull($result);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
544
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
545 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
546
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
547 function testNoComponents() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
548
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
549 $input = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
550 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
551 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
552 PRODID:vobject
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
553 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
554 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
555
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
556 $this->assertValidate(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
557 $input,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
558 0,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
559 3,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
560 "An iCalendar object must have at least 1 component."
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
561 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
562
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
563 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
564
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
565 function testCalDAVNoComponents() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
566
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
567 $input = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
568 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
569 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
570 PRODID:vobject
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
571 BEGIN:VTIMEZONE
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
572 TZID:America/Toronto
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
573 END:VTIMEZONE
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
574 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
575 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
576
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
577 $this->assertValidate(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
578 $input,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
579 VCalendar::PROFILE_CALDAV,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
580 3,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
581 "A calendar object on a CalDAV server must have at least 1 component (VTODO, VEVENT, VJOURNAL)."
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
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
586 function testCalDAVMultiUID() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
587
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
588 $input = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
589 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
590 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
591 PRODID:vobject
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
592 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
593 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
594 DTSTAMP:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
595 DTSTART:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
596 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
597 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
598 UID:bar
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
599 DTSTAMP:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
600 DTSTART:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
601 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
602 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
603 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
604
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
605 $this->assertValidate(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
606 $input,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
607 VCalendar::PROFILE_CALDAV,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
608 3,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
609 "A calendar object on a CalDAV server may only have components with the same UID."
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
610 );
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 function testCalDAVMultiComponent() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
615
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
616 $input = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
617 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
618 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
619 PRODID:vobject
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
620 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
621 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
622 RECURRENCE-ID:20150109T185200Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
623 DTSTAMP:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
624 DTSTART:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
625 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
626 BEGIN:VTODO
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
627 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
628 DTSTAMP:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
629 DTSTART:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
630 END:VTODO
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
631 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
632 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
633
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
634 $this->assertValidate(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
635 $input,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
636 VCalendar::PROFILE_CALDAV,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
637 3,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
638 "A calendar object on a CalDAV server may only have 1 type of component (VEVENT, VTODO or VJOURNAL)."
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
639 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
640
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
641 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
642
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
643 function testCalDAVMETHOD() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
644
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
645 $input = <<<ICS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
646 BEGIN:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
647 VERSION:2.0
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
648 METHOD:PUBLISH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
649 PRODID:vobject
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
650 BEGIN:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
651 UID:foo
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
652 RECURRENCE-ID:20150109T185200Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
653 DTSTAMP:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
654 DTSTART:20150109T184500Z
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
655 END:VEVENT
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
656 END:VCALENDAR
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
657 ICS;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
658
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
659 $this->assertValidate(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
660 $input,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
661 VCalendar::PROFILE_CALDAV,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
662 3,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
663 "A calendar object on a CalDAV server MUST NOT have a METHOD property."
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
664 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
665
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
666 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
667
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
668 function assertValidate($ics, $options, $expectedLevel, $expectedMessage = null) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
669
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
670 $vcal = VObject\Reader::read($ics);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
671 $result = $vcal->validate($options);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
672
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
673 $this->assertValidateResult($result, $expectedLevel, $expectedMessage);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
674
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
675 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
676
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
677 function assertValidateResult($input, $expectedLevel, $expectedMessage = null) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
678
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
679 $messages = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
680 foreach($input as $warning) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
681 $messages[] = $warning['message'];
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 if ($expectedLevel === 0) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
685 $this->assertEquals(0, count($input), 'No validation messages were expected. We got: ' . implode(', ', $messages));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
686 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
687 $this->assertEquals(1, count($input), 'We expected exactly 1 validation message, We got: ' . implode(', ', $messages));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
688
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
689 $this->assertEquals($expectedMessage, $input[0]['message']);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
690 $this->assertEquals($expectedLevel, $input[0]['level']);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
691 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
692
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
693 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
694
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
695
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
696 }