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