Mercurial > hg > rc1
comparison vendor/sabre/vobject/tests/VObject/ITip/BrokerNewEventTest.php @ 7:430dbd5346f7
vendor sabre as distributed
author | Charlie Root |
---|---|
date | Sat, 13 Jan 2018 09:06:10 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
6:cec75ba50afc | 7:430dbd5346f7 |
---|---|
1 <?php | |
2 | |
3 namespace Sabre\VObject\ITip; | |
4 | |
5 class BrokerNewEventTest extends \PHPUnit_Framework_TestCase { | |
6 | |
7 function testNoAttendee() { | |
8 | |
9 $message = <<<ICS | |
10 BEGIN:VCALENDAR | |
11 BEGIN:VEVENT | |
12 UID:foobar | |
13 DTSTART:20140811T220000Z | |
14 END:VEVENT | |
15 END:VCALENDAR | |
16 ICS; | |
17 | |
18 $result = $this->parse($message); | |
19 | |
20 } | |
21 | |
22 function testVTODO() { | |
23 | |
24 $message = <<<ICS | |
25 BEGIN:VCALENDAR | |
26 BEGIN:VTODO | |
27 UID:foobar | |
28 END:VTODO | |
29 END:VCALENDAR | |
30 ICS; | |
31 | |
32 $result = $this->parse($message); | |
33 | |
34 } | |
35 | |
36 function testSimpleInvite() { | |
37 | |
38 $message = <<<ICS | |
39 BEGIN:VCALENDAR | |
40 VERSION:2.0 | |
41 BEGIN:VEVENT | |
42 UID:foobar | |
43 DTSTART:20140811T220000Z | |
44 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
45 ATTENDEE;CN=White:mailto:white@example.org | |
46 END:VEVENT | |
47 END:VCALENDAR | |
48 ICS; | |
49 | |
50 $version = \Sabre\VObject\Version::VERSION; | |
51 $expectedMessage = <<<ICS | |
52 BEGIN:VCALENDAR | |
53 VERSION:2.0 | |
54 PRODID:-//Sabre//Sabre VObject $version//EN | |
55 CALSCALE:GREGORIAN | |
56 METHOD:REQUEST | |
57 BEGIN:VEVENT | |
58 UID:foobar | |
59 DTSTART:20140811T220000Z | |
60 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
61 ATTENDEE;CN=White;PARTSTAT=NEEDS-ACTION:mailto:white@example.org | |
62 END:VEVENT | |
63 END:VCALENDAR | |
64 ICS; | |
65 | |
66 $expected = array( | |
67 array( | |
68 'uid' => 'foobar', | |
69 'method' => 'REQUEST', | |
70 'component' => 'VEVENT', | |
71 'sender' => 'mailto:strunk@example.org', | |
72 'senderName' => 'Strunk', | |
73 'recipient' => 'mailto:white@example.org', | |
74 'recipientName' => 'White', | |
75 'message' => $expectedMessage, | |
76 ), | |
77 ); | |
78 | |
79 $result = $this->parse($message, $expected); | |
80 | |
81 } | |
82 | |
83 /** | |
84 * @expectedException \Sabre\VObject\ITip\ITipException | |
85 */ | |
86 function testBrokenEventUIDMisMatch() { | |
87 | |
88 $message = <<<ICS | |
89 BEGIN:VCALENDAR | |
90 VERSION:2.0 | |
91 BEGIN:VEVENT | |
92 UID:foobar | |
93 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
94 ATTENDEE;CN=White:mailto:white@example.org | |
95 END:VEVENT | |
96 BEGIN:VEVENT | |
97 UID:foobar2 | |
98 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
99 ATTENDEE;CN=White:mailto:white@example.org | |
100 END:VEVENT | |
101 END:VCALENDAR | |
102 ICS; | |
103 | |
104 $expected = array(); | |
105 $this->parse($message, array()); | |
106 | |
107 } | |
108 /** | |
109 * @expectedException \Sabre\VObject\ITip\ITipException | |
110 */ | |
111 function testBrokenEventOrganizerMisMatch() { | |
112 | |
113 $message = <<<ICS | |
114 BEGIN:VCALENDAR | |
115 VERSION:2.0 | |
116 BEGIN:VEVENT | |
117 UID:foobar | |
118 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
119 ATTENDEE;CN=White:mailto:white@example.org | |
120 END:VEVENT | |
121 BEGIN:VEVENT | |
122 UID:foobar | |
123 ORGANIZER:mailto:foo@example.org | |
124 ATTENDEE;CN=White:mailto:white@example.org | |
125 END:VEVENT | |
126 END:VCALENDAR | |
127 ICS; | |
128 | |
129 $expected = array(); | |
130 $this->parse($message, array()); | |
131 | |
132 } | |
133 | |
134 function testRecurrenceInvite() { | |
135 | |
136 $message = <<<ICS | |
137 BEGIN:VCALENDAR | |
138 VERSION:2.0 | |
139 BEGIN:VEVENT | |
140 UID:foobar | |
141 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
142 ATTENDEE;CN=One:mailto:one@example.org | |
143 ATTENDEE;CN=Two:mailto:two@example.org | |
144 DTSTART:20140716T120000Z | |
145 RRULE:FREQ=DAILY | |
146 EXDATE:20140717T120000Z | |
147 END:VEVENT | |
148 BEGIN:VEVENT | |
149 UID:foobar | |
150 RECURRENCE-ID:20140718T120000Z | |
151 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
152 ATTENDEE;CN=Two:mailto:two@example.org | |
153 ATTENDEE;CN=Three:mailto:three@example.org | |
154 DTSTART:20140718T120000Z | |
155 END:VEVENT | |
156 END:VCALENDAR | |
157 ICS; | |
158 | |
159 $version = \Sabre\VObject\Version::VERSION; | |
160 | |
161 $expected = array( | |
162 array( | |
163 'uid' => 'foobar', | |
164 'method' => 'REQUEST', | |
165 'component' => 'VEVENT', | |
166 'sender' => 'mailto:strunk@example.org', | |
167 'senderName' => 'Strunk', | |
168 'recipient' => 'mailto:one@example.org', | |
169 'recipientName' => 'One', | |
170 'message' => <<<ICS | |
171 BEGIN:VCALENDAR | |
172 VERSION:2.0 | |
173 PRODID:-//Sabre//Sabre VObject $version//EN | |
174 CALSCALE:GREGORIAN | |
175 METHOD:REQUEST | |
176 BEGIN:VEVENT | |
177 UID:foobar | |
178 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
179 ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org | |
180 ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org | |
181 DTSTART:20140716T120000Z | |
182 RRULE:FREQ=DAILY | |
183 EXDATE:20140717T120000Z,20140718T120000Z | |
184 END:VEVENT | |
185 END:VCALENDAR | |
186 ICS | |
187 | |
188 ), | |
189 array( | |
190 'uid' => 'foobar', | |
191 'method' => 'REQUEST', | |
192 'component' => 'VEVENT', | |
193 'sender' => 'mailto:strunk@example.org', | |
194 'senderName' => 'Strunk', | |
195 'recipient' => 'mailto:two@example.org', | |
196 'recipientName' => 'Two', | |
197 'message' => <<<ICS | |
198 BEGIN:VCALENDAR | |
199 VERSION:2.0 | |
200 PRODID:-//Sabre//Sabre VObject $version//EN | |
201 CALSCALE:GREGORIAN | |
202 METHOD:REQUEST | |
203 BEGIN:VEVENT | |
204 UID:foobar | |
205 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
206 ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org | |
207 ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org | |
208 DTSTART:20140716T120000Z | |
209 RRULE:FREQ=DAILY | |
210 EXDATE:20140717T120000Z | |
211 END:VEVENT | |
212 BEGIN:VEVENT | |
213 UID:foobar | |
214 RECURRENCE-ID:20140718T120000Z | |
215 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
216 ATTENDEE;CN=Two:mailto:two@example.org | |
217 ATTENDEE;CN=Three:mailto:three@example.org | |
218 DTSTART:20140718T120000Z | |
219 END:VEVENT | |
220 END:VCALENDAR | |
221 ICS | |
222 | |
223 ), | |
224 array( | |
225 'uid' => 'foobar', | |
226 'method' => 'REQUEST', | |
227 'component' => 'VEVENT', | |
228 'sender' => 'mailto:strunk@example.org', | |
229 'senderName' => 'Strunk', | |
230 'recipient' => 'mailto:three@example.org', | |
231 'recipientName' => 'Three', | |
232 'message' => <<<ICS | |
233 BEGIN:VCALENDAR | |
234 VERSION:2.0 | |
235 PRODID:-//Sabre//Sabre VObject $version//EN | |
236 CALSCALE:GREGORIAN | |
237 METHOD:REQUEST | |
238 BEGIN:VEVENT | |
239 UID:foobar | |
240 RECURRENCE-ID:20140718T120000Z | |
241 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
242 ATTENDEE;CN=Two:mailto:two@example.org | |
243 ATTENDEE;CN=Three:mailto:three@example.org | |
244 DTSTART:20140718T120000Z | |
245 END:VEVENT | |
246 END:VCALENDAR | |
247 ICS | |
248 | |
249 ), | |
250 ); | |
251 | |
252 $result = $this->parse($message, $expected); | |
253 | |
254 } | |
255 | |
256 function testRecurrenceInvite2() { | |
257 | |
258 // This method tests a nearly identical path, but in this case the | |
259 // master event does not have an EXDATE. | |
260 $message = <<<ICS | |
261 BEGIN:VCALENDAR | |
262 VERSION:2.0 | |
263 BEGIN:VEVENT | |
264 UID:foobar | |
265 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
266 ATTENDEE;CN=One:mailto:one@example.org | |
267 ATTENDEE;CN=Two:mailto:two@example.org | |
268 DTSTART:20140716T120000Z | |
269 RRULE:FREQ=DAILY | |
270 END:VEVENT | |
271 BEGIN:VEVENT | |
272 UID:foobar | |
273 RECURRENCE-ID:20140718T120000Z | |
274 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
275 ATTENDEE;CN=Two:mailto:two@example.org | |
276 ATTENDEE;CN=Three:mailto:three@example.org | |
277 DTSTART:20140718T120000Z | |
278 END:VEVENT | |
279 END:VCALENDAR | |
280 ICS; | |
281 | |
282 $version = \Sabre\VObject\Version::VERSION; | |
283 | |
284 $expected = array( | |
285 array( | |
286 'uid' => 'foobar', | |
287 'method' => 'REQUEST', | |
288 'component' => 'VEVENT', | |
289 'sender' => 'mailto:strunk@example.org', | |
290 'senderName' => 'Strunk', | |
291 'recipient' => 'mailto:one@example.org', | |
292 'recipientName' => 'One', | |
293 'message' => <<<ICS | |
294 BEGIN:VCALENDAR | |
295 VERSION:2.0 | |
296 PRODID:-//Sabre//Sabre VObject $version//EN | |
297 CALSCALE:GREGORIAN | |
298 METHOD:REQUEST | |
299 BEGIN:VEVENT | |
300 UID:foobar | |
301 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
302 ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org | |
303 ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org | |
304 DTSTART:20140716T120000Z | |
305 RRULE:FREQ=DAILY | |
306 EXDATE:20140718T120000Z | |
307 END:VEVENT | |
308 END:VCALENDAR | |
309 ICS | |
310 | |
311 ), | |
312 array( | |
313 'uid' => 'foobar', | |
314 'method' => 'REQUEST', | |
315 'component' => 'VEVENT', | |
316 'sender' => 'mailto:strunk@example.org', | |
317 'senderName' => 'Strunk', | |
318 'recipient' => 'mailto:two@example.org', | |
319 'recipientName' => 'Two', | |
320 'message' => <<<ICS | |
321 BEGIN:VCALENDAR | |
322 VERSION:2.0 | |
323 PRODID:-//Sabre//Sabre VObject $version//EN | |
324 CALSCALE:GREGORIAN | |
325 METHOD:REQUEST | |
326 BEGIN:VEVENT | |
327 UID:foobar | |
328 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
329 ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org | |
330 ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org | |
331 DTSTART:20140716T120000Z | |
332 RRULE:FREQ=DAILY | |
333 END:VEVENT | |
334 BEGIN:VEVENT | |
335 UID:foobar | |
336 RECURRENCE-ID:20140718T120000Z | |
337 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
338 ATTENDEE;CN=Two:mailto:two@example.org | |
339 ATTENDEE;CN=Three:mailto:three@example.org | |
340 DTSTART:20140718T120000Z | |
341 END:VEVENT | |
342 END:VCALENDAR | |
343 ICS | |
344 | |
345 ), | |
346 array( | |
347 'uid' => 'foobar', | |
348 'method' => 'REQUEST', | |
349 'component' => 'VEVENT', | |
350 'sender' => 'mailto:strunk@example.org', | |
351 'senderName' => 'Strunk', | |
352 'recipient' => 'mailto:three@example.org', | |
353 'recipientName' => 'Three', | |
354 'message' => <<<ICS | |
355 BEGIN:VCALENDAR | |
356 VERSION:2.0 | |
357 PRODID:-//Sabre//Sabre VObject $version//EN | |
358 CALSCALE:GREGORIAN | |
359 METHOD:REQUEST | |
360 BEGIN:VEVENT | |
361 UID:foobar | |
362 RECURRENCE-ID:20140718T120000Z | |
363 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
364 ATTENDEE;CN=Two:mailto:two@example.org | |
365 ATTENDEE;CN=Three:mailto:three@example.org | |
366 DTSTART:20140718T120000Z | |
367 END:VEVENT | |
368 END:VCALENDAR | |
369 ICS | |
370 | |
371 ), | |
372 ); | |
373 | |
374 $result = $this->parse($message, $expected); | |
375 | |
376 } | |
377 | |
378 function testScheduleAgentClient() { | |
379 | |
380 $message = <<<ICS | |
381 BEGIN:VCALENDAR | |
382 VERSION:2.0 | |
383 BEGIN:VEVENT | |
384 UID:foobar | |
385 DTSTART:20140811T220000Z | |
386 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
387 ATTENDEE;CN=White;SCHEDULE-AGENT=CLIENT:mailto:white@example.org | |
388 END:VEVENT | |
389 END:VCALENDAR | |
390 ICS; | |
391 | |
392 $version = \Sabre\VObject\Version::VERSION; | |
393 | |
394 $expected = array(); | |
395 $result = $this->parse($message, $expected); | |
396 | |
397 } | |
398 | |
399 /** | |
400 * @expectedException Sabre\VObject\ITip\ITipException | |
401 */ | |
402 function testMultipleUID() { | |
403 | |
404 $message = <<<ICS | |
405 BEGIN:VCALENDAR | |
406 VERSION:2.0 | |
407 BEGIN:VEVENT | |
408 UID:foobar | |
409 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
410 ATTENDEE;CN=One:mailto:one@example.org | |
411 ATTENDEE;CN=Two:mailto:two@example.org | |
412 DTSTART:20140716T120000Z | |
413 RRULE:FREQ=DAILY | |
414 END:VEVENT | |
415 BEGIN:VEVENT | |
416 UID:foobar2 | |
417 RECURRENCE-ID:20140718T120000Z | |
418 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
419 ATTENDEE;CN=Two:mailto:two@example.org | |
420 ATTENDEE;CN=Three:mailto:three@example.org | |
421 DTSTART:20140718T120000Z | |
422 END:VEVENT | |
423 END:VCALENDAR | |
424 ICS; | |
425 | |
426 $version = \Sabre\VObject\Version::VERSION; | |
427 $result = $this->parse($message, array()); | |
428 | |
429 } | |
430 | |
431 /** | |
432 * @expectedException Sabre\VObject\ITip\SameOrganizerForAllComponentsException | |
433 * | |
434 */ | |
435 function testChangingOrganizers() { | |
436 | |
437 $message = <<<ICS | |
438 BEGIN:VCALENDAR | |
439 VERSION:2.0 | |
440 BEGIN:VEVENT | |
441 UID:foobar | |
442 ORGANIZER;CN=Strunk:mailto:strunk@example.org | |
443 ATTENDEE;CN=One:mailto:one@example.org | |
444 ATTENDEE;CN=Two:mailto:two@example.org | |
445 DTSTART:20140716T120000Z | |
446 RRULE:FREQ=DAILY | |
447 END:VEVENT | |
448 BEGIN:VEVENT | |
449 UID:foobar | |
450 RECURRENCE-ID:20140718T120000Z | |
451 ORGANIZER;CN=Strunk:mailto:ew@example.org | |
452 ATTENDEE;CN=Two:mailto:two@example.org | |
453 ATTENDEE;CN=Three:mailto:three@example.org | |
454 DTSTART:20140718T120000Z | |
455 END:VEVENT | |
456 END:VCALENDAR | |
457 ICS; | |
458 | |
459 $version = \Sabre\VObject\Version::VERSION; | |
460 $result = $this->parse($message, array()); | |
461 | |
462 } | |
463 function testNoOrganizerHasAttendee() { | |
464 | |
465 $message = <<<ICS | |
466 BEGIN:VCALENDAR | |
467 BEGIN:VEVENT | |
468 UID:foobar | |
469 DTSTART:20140811T220000Z | |
470 ATTENDEE;CN=Two:mailto:two@example.org | |
471 END:VEVENT | |
472 END:VCALENDAR | |
473 ICS; | |
474 | |
475 $this->parse($message, array()); | |
476 | |
477 } | |
478 | |
479 function parse($message, $expected = array()) { | |
480 | |
481 $broker = new Broker(); | |
482 $result = $broker->parseEvent($message, 'mailto:strunk@example.org'); | |
483 | |
484 $this->assertEquals(count($expected), count($result)); | |
485 | |
486 foreach($expected as $index=>$ex) { | |
487 | |
488 $message = $result[$index]; | |
489 | |
490 foreach($ex as $key=>$val) { | |
491 | |
492 if ($key==='message') { | |
493 $this->assertEquals( | |
494 str_replace("\n", "\r\n", $val), | |
495 rtrim($message->message->serialize(), "\r\n") | |
496 ); | |
497 } else { | |
498 $this->assertEquals($val, $message->$key); | |
499 } | |
500 | |
501 } | |
502 | |
503 } | |
504 | |
505 } | |
506 | |
507 } |