1<?php
2
3namespace Sabre\VObject\ITip;
4
5class BrokerDeleteEventTest extends BrokerTester {
6
7    function testOrganizerDeleteWithDtend() {
8
9        $oldMessage = <<<ICS
10BEGIN:VCALENDAR
11VERSION:2.0
12BEGIN:VEVENT
13UID:foobar
14SEQUENCE:1
15SUMMARY:foo
16ORGANIZER;CN=Strunk:mailto:strunk@example.org
17ATTENDEE;CN=One:mailto:one@example.org
18ATTENDEE;CN=Two:mailto:two@example.org
19DTSTART:20140716T120000Z
20DTEND:20140716T130000Z
21END:VEVENT
22END:VCALENDAR
23ICS;
24
25
26        $newMessage = null;
27
28        $version = \Sabre\VObject\Version::VERSION;
29
30        $expected = [
31            [
32                'uid'           => 'foobar',
33                'method'        => 'CANCEL',
34                'component'     => 'VEVENT',
35                'sender'        => 'mailto:strunk@example.org',
36                'senderName'    => 'Strunk',
37                'recipient'     => 'mailto:one@example.org',
38                'recipientName' => 'One',
39                'message'       => <<<ICS
40BEGIN:VCALENDAR
41VERSION:2.0
42PRODID:-//Sabre//Sabre VObject $version//EN
43CALSCALE:GREGORIAN
44METHOD:CANCEL
45BEGIN:VEVENT
46UID:foobar
47DTSTAMP:**ANY**
48SEQUENCE:2
49SUMMARY:foo
50DTSTART:20140716T120000Z
51DTEND:20140716T130000Z
52ORGANIZER;CN=Strunk:mailto:strunk@example.org
53ATTENDEE;CN=One:mailto:one@example.org
54END:VEVENT
55END:VCALENDAR
56ICS
57            ],
58
59            [
60                'uid'           => 'foobar',
61                'method'        => 'CANCEL',
62                'component'     => 'VEVENT',
63                'sender'        => 'mailto:strunk@example.org',
64                'senderName'    => 'Strunk',
65                'recipient'     => 'mailto:two@example.org',
66                'recipientName' => 'Two',
67                'message'       => <<<ICS
68BEGIN:VCALENDAR
69VERSION:2.0
70PRODID:-//Sabre//Sabre VObject $version//EN
71CALSCALE:GREGORIAN
72METHOD:CANCEL
73BEGIN:VEVENT
74UID:foobar
75DTSTAMP:**ANY**
76SEQUENCE:2
77SUMMARY:foo
78DTSTART:20140716T120000Z
79DTEND:20140716T130000Z
80ORGANIZER;CN=Strunk:mailto:strunk@example.org
81ATTENDEE;CN=Two:mailto:two@example.org
82END:VEVENT
83END:VCALENDAR
84ICS
85
86            ],
87        ];
88
89        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk@example.org');
90
91    }
92
93    function testOrganizerDeleteWithDuration() {
94
95        $oldMessage = <<<ICS
96BEGIN:VCALENDAR
97VERSION:2.0
98BEGIN:VEVENT
99UID:foobar
100SEQUENCE:1
101SUMMARY:foo
102ORGANIZER;CN=Strunk:mailto:strunk@example.org
103ATTENDEE;CN=One:mailto:one@example.org
104ATTENDEE;CN=Two:mailto:two@example.org
105DTSTART:20140716T120000Z
106DURATION:PT1H
107END:VEVENT
108END:VCALENDAR
109ICS;
110
111
112        $newMessage = null;
113
114        $version = \Sabre\VObject\Version::VERSION;
115
116        $expected = [
117            [
118                'uid'           => 'foobar',
119                'method'        => 'CANCEL',
120                'component'     => 'VEVENT',
121                'sender'        => 'mailto:strunk@example.org',
122                'senderName'    => 'Strunk',
123                'recipient'     => 'mailto:one@example.org',
124                'recipientName' => 'One',
125                'message'       => <<<ICS
126BEGIN:VCALENDAR
127VERSION:2.0
128PRODID:-//Sabre//Sabre VObject $version//EN
129CALSCALE:GREGORIAN
130METHOD:CANCEL
131BEGIN:VEVENT
132UID:foobar
133DTSTAMP:**ANY**
134SEQUENCE:2
135SUMMARY:foo
136DTSTART:20140716T120000Z
137DURATION:PT1H
138ORGANIZER;CN=Strunk:mailto:strunk@example.org
139ATTENDEE;CN=One:mailto:one@example.org
140END:VEVENT
141END:VCALENDAR
142ICS
143            ],
144
145            [
146                'uid'           => 'foobar',
147                'method'        => 'CANCEL',
148                'component'     => 'VEVENT',
149                'sender'        => 'mailto:strunk@example.org',
150                'senderName'    => 'Strunk',
151                'recipient'     => 'mailto:two@example.org',
152                'recipientName' => 'Two',
153                'message'       => <<<ICS
154BEGIN:VCALENDAR
155VERSION:2.0
156PRODID:-//Sabre//Sabre VObject $version//EN
157CALSCALE:GREGORIAN
158METHOD:CANCEL
159BEGIN:VEVENT
160UID:foobar
161DTSTAMP:**ANY**
162SEQUENCE:2
163SUMMARY:foo
164DTSTART:20140716T120000Z
165DURATION:PT1H
166ORGANIZER;CN=Strunk:mailto:strunk@example.org
167ATTENDEE;CN=Two:mailto:two@example.org
168END:VEVENT
169END:VCALENDAR
170ICS
171
172            ],
173        ];
174
175        $this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk@example.org');
176
177    }
178
179    function testAttendeeDeleteWithDtend() {
180
181        $oldMessage = <<<ICS
182BEGIN:VCALENDAR
183VERSION:2.0
184BEGIN:VEVENT
185UID:foobar
186SEQUENCE:1
187SUMMARY:foo
188ORGANIZER;CN=Strunk:mailto:strunk@example.org
189ATTENDEE;CN=One:mailto:one@example.org
190ATTENDEE;CN=Two:mailto:two@example.org
191DTSTART:20140716T120000Z
192DTEND:20140716T130000Z
193END:VEVENT
194END:VCALENDAR
195ICS;
196
197
198        $newMessage = null;
199
200        $version = \Sabre\VObject\Version::VERSION;
201
202        $expected = [
203            [
204                'uid'           => 'foobar',
205                'method'        => 'REPLY',
206                'component'     => 'VEVENT',
207                'sender'        => 'mailto:one@example.org',
208                'senderName'    => 'One',
209                'recipient'     => 'mailto:strunk@example.org',
210                'recipientName' => 'Strunk',
211                'message'       => <<<ICS
212BEGIN:VCALENDAR
213VERSION:2.0
214PRODID:-//Sabre//Sabre VObject $version//EN
215CALSCALE:GREGORIAN
216METHOD:REPLY
217BEGIN:VEVENT
218UID:foobar
219DTSTAMP:**ANY**
220SEQUENCE:1
221DTSTART:20140716T120000Z
222DTEND:20140716T130000Z
223SUMMARY:foo
224ORGANIZER;CN=Strunk:mailto:strunk@example.org
225ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
226END:VEVENT
227END:VCALENDAR
228ICS
229            ],
230        ];
231
232        $this->parse($oldMessage, $newMessage, $expected, 'mailto:one@example.org');
233
234
235    }
236
237    function testAttendeeReplyWithDuration() {
238
239        $oldMessage = <<<ICS
240BEGIN:VCALENDAR
241VERSION:2.0
242BEGIN:VEVENT
243UID:foobar
244SEQUENCE:1
245SUMMARY:foo
246ORGANIZER;CN=Strunk:mailto:strunk@example.org
247ATTENDEE;CN=One:mailto:one@example.org
248ATTENDEE;CN=Two:mailto:two@example.org
249DTSTART:20140716T120000Z
250DURATION:PT1H
251END:VEVENT
252END:VCALENDAR
253ICS;
254
255
256        $newMessage = null;
257
258        $version = \Sabre\VObject\Version::VERSION;
259
260        $expected = [
261            [
262                'uid'           => 'foobar',
263                'method'        => 'REPLY',
264                'component'     => 'VEVENT',
265                'sender'        => 'mailto:one@example.org',
266                'senderName'    => 'One',
267                'recipient'     => 'mailto:strunk@example.org',
268                'recipientName' => 'Strunk',
269                'message'       => <<<ICS
270BEGIN:VCALENDAR
271VERSION:2.0
272PRODID:-//Sabre//Sabre VObject $version//EN
273CALSCALE:GREGORIAN
274METHOD:REPLY
275BEGIN:VEVENT
276UID:foobar
277DTSTAMP:**ANY**
278SEQUENCE:1
279DTSTART:20140716T120000Z
280DURATION:PT1H
281SUMMARY:foo
282ORGANIZER;CN=Strunk:mailto:strunk@example.org
283ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
284END:VEVENT
285END:VCALENDAR
286ICS
287            ],
288        ];
289
290        $this->parse($oldMessage, $newMessage, $expected, 'mailto:one@example.org');
291
292
293    }
294
295    function testAttendeeDeleteCancelledEvent() {
296
297        $oldMessage = <<<ICS
298BEGIN:VCALENDAR
299VERSION:2.0
300BEGIN:VEVENT
301STATUS:CANCELLED
302UID:foobar
303SEQUENCE:1
304ORGANIZER;CN=Strunk:mailto:strunk@example.org
305ATTENDEE;CN=One:mailto:one@example.org
306ATTENDEE;CN=Two:mailto:two@example.org
307DTSTART:20140716T120000Z
308DTEND:20140716T130000Z
309END:VEVENT
310END:VCALENDAR
311ICS;
312
313
314        $newMessage = null;
315
316        $expected = [];
317
318        $this->parse($oldMessage, $newMessage, $expected, 'mailto:one@example.org');
319
320
321    }
322
323    function testNoCalendar() {
324
325        $this->parse(null, null, [], 'mailto:one@example.org');
326
327    }
328
329    function testVTodo() {
330
331        $oldMessage = <<<ICS
332BEGIN:VCALENDAR
333VERSION:2.0
334BEGIN:VTODO
335UID:foobar
336SEQUENCE:1
337END:VTODO
338END:VCALENDAR
339ICS;
340        $this->parse($oldMessage, null, [], 'mailto:one@example.org');
341
342    }
343
344}
345