1<?php 2 3namespace Sabre\VObject\ITip; 4 5class BrokerProcessReplyTest extends BrokerTester { 6 7 function testReplyNoOriginal() { 8 9 $itip = <<<ICS 10BEGIN:VCALENDAR 11VERSION:2.0 12METHOD:REPLY 13BEGIN:VEVENT 14SEQUENCE:2 15UID:foobar 16ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 17ORGANIZER:mailto:bar@example.org 18END:VEVENT 19END:VCALENDAR 20ICS; 21 22 $old = null; 23 $expected = null; 24 25 $result = $this->process($itip, $old, $expected); 26 27 } 28 29 function testReplyAccept() { 30 31 $itip = <<<ICS 32BEGIN:VCALENDAR 33VERSION:2.0 34METHOD:REPLY 35BEGIN:VEVENT 36ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 37ORGANIZER:mailto:bar@example.org 38SEQUENCE:2 39UID:foobar 40END:VEVENT 41END:VCALENDAR 42ICS; 43 44 $old = <<<ICS 45BEGIN:VCALENDAR 46VERSION:2.0 47BEGIN:VEVENT 48SEQUENCE:2 49UID:foobar 50ATTENDEE:mailto:foo@example.org 51ORGANIZER:mailto:bar@example.org 52END:VEVENT 53END:VCALENDAR 54ICS; 55 56 $expected = <<<ICS 57BEGIN:VCALENDAR 58VERSION:2.0 59BEGIN:VEVENT 60SEQUENCE:2 61UID:foobar 62ATTENDEE;PARTSTAT=ACCEPTED;SCHEDULE-STATUS=2.0:mailto:foo@example.org 63ORGANIZER:mailto:bar@example.org 64END:VEVENT 65END:VCALENDAR 66ICS; 67 68 $result = $this->process($itip, $old, $expected); 69 70 } 71 72 function testReplyRequestStatus() { 73 74 $itip = <<<ICS 75BEGIN:VCALENDAR 76VERSION:2.0 77METHOD:REPLY 78BEGIN:VEVENT 79UID:foobar 80REQUEST-STATUS:2.3;foo-bar! 81ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 82ORGANIZER:mailto:bar@example.org 83SEQUENCE:2 84UID:foobar 85END:VEVENT 86END:VCALENDAR 87ICS; 88 89 $old = <<<ICS 90BEGIN:VCALENDAR 91VERSION:2.0 92BEGIN:VEVENT 93UID:foobar 94SEQUENCE:2 95ATTENDEE:mailto:foo@example.org 96ORGANIZER:mailto:bar@example.org 97END:VEVENT 98END:VCALENDAR 99ICS; 100 101 $expected = <<<ICS 102BEGIN:VCALENDAR 103VERSION:2.0 104BEGIN:VEVENT 105UID:foobar 106SEQUENCE:2 107ATTENDEE;PARTSTAT=ACCEPTED;SCHEDULE-STATUS=2.3:mailto:foo@example.org 108ORGANIZER:mailto:bar@example.org 109END:VEVENT 110END:VCALENDAR 111ICS; 112 113 $result = $this->process($itip, $old, $expected); 114 115 } 116 117 118 function testReplyPartyCrasher() { 119 120 $itip = <<<ICS 121BEGIN:VCALENDAR 122VERSION:2.0 123METHOD:REPLY 124BEGIN:VEVENT 125ATTENDEE;PARTSTAT=ACCEPTED:mailto:crasher@example.org 126ORGANIZER:mailto:bar@example.org 127SEQUENCE:2 128UID:foobar 129END:VEVENT 130END:VCALENDAR 131ICS; 132 133 $old = <<<ICS 134BEGIN:VCALENDAR 135VERSION:2.0 136BEGIN:VEVENT 137SEQUENCE:2 138UID:foobar 139ATTENDEE:mailto:foo@example.org 140ORGANIZER:mailto:bar@example.org 141END:VEVENT 142END:VCALENDAR 143ICS; 144 145 $expected = <<<ICS 146BEGIN:VCALENDAR 147VERSION:2.0 148BEGIN:VEVENT 149SEQUENCE:2 150UID:foobar 151ATTENDEE:mailto:foo@example.org 152ORGANIZER:mailto:bar@example.org 153ATTENDEE;PARTSTAT=ACCEPTED:mailto:crasher@example.org 154END:VEVENT 155END:VCALENDAR 156ICS; 157 158 $result = $this->process($itip, $old, $expected); 159 160 } 161 162 function testReplyNewException() { 163 164 // This is a reply to 1 instance of a recurring event. This should 165 // automatically create an exception. 166 $itip = <<<ICS 167BEGIN:VCALENDAR 168VERSION:2.0 169METHOD:REPLY 170BEGIN:VEVENT 171ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 172ORGANIZER:mailto:bar@example.org 173SEQUENCE:2 174RECURRENCE-ID:20140725T000000Z 175UID:foobar 176END:VEVENT 177END:VCALENDAR 178ICS; 179 180 $old = <<<ICS 181BEGIN:VCALENDAR 182VERSION:2.0 183BEGIN:VEVENT 184SEQUENCE:2 185UID:foobar 186RRULE:FREQ=DAILY 187DTSTART:20140724T000000Z 188ATTENDEE:mailto:foo@example.org 189ORGANIZER:mailto:bar@example.org 190END:VEVENT 191END:VCALENDAR 192ICS; 193 194 $expected = <<<ICS 195BEGIN:VCALENDAR 196VERSION:2.0 197BEGIN:VEVENT 198SEQUENCE:2 199UID:foobar 200RRULE:FREQ=DAILY 201DTSTART:20140724T000000Z 202ATTENDEE:mailto:foo@example.org 203ORGANIZER:mailto:bar@example.org 204END:VEVENT 205BEGIN:VEVENT 206SEQUENCE:2 207UID:foobar 208DTSTART:20140725T000000Z 209ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 210ORGANIZER:mailto:bar@example.org 211RECURRENCE-ID:20140725T000000Z 212END:VEVENT 213END:VCALENDAR 214ICS; 215 216 $result = $this->process($itip, $old, $expected); 217 218 } 219 220 function testReplyNewExceptionTz() { 221 222 // This is a reply to 1 instance of a recurring event. This should 223 // automatically create an exception. 224 $itip = <<<ICS 225BEGIN:VCALENDAR 226VERSION:2.0 227METHOD:REPLY 228BEGIN:VEVENT 229ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 230ORGANIZER:mailto:bar@example.org 231SEQUENCE:2 232RECURRENCE-ID;TZID=America/Toronto:20140725T000000 233UID:foobar 234END:VEVENT 235END:VCALENDAR 236ICS; 237 238 $old = <<<ICS 239BEGIN:VCALENDAR 240VERSION:2.0 241BEGIN:VEVENT 242SEQUENCE:2 243UID:foobar 244RRULE:FREQ=DAILY 245DTSTART;TZID=America/Toronto:20140724T000000 246ATTENDEE:mailto:foo@example.org 247ORGANIZER:mailto:bar@example.org 248END:VEVENT 249END:VCALENDAR 250ICS; 251 252 $expected = <<<ICS 253BEGIN:VCALENDAR 254VERSION:2.0 255BEGIN:VEVENT 256SEQUENCE:2 257UID:foobar 258RRULE:FREQ=DAILY 259DTSTART;TZID=America/Toronto:20140724T000000 260ATTENDEE:mailto:foo@example.org 261ORGANIZER:mailto:bar@example.org 262END:VEVENT 263BEGIN:VEVENT 264SEQUENCE:2 265UID:foobar 266DTSTART;TZID=America/Toronto:20140725T000000 267ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 268ORGANIZER:mailto:bar@example.org 269RECURRENCE-ID;TZID=America/Toronto:20140725T000000 270END:VEVENT 271END:VCALENDAR 272ICS; 273 274 $result = $this->process($itip, $old, $expected); 275 276 } 277 278 function testReplyPartyCrashCreateExcepton() { 279 280 // IN this test there's a recurring event that has an exception. The 281 // exception is missing the attendee. 282 // 283 // The attendee party crashes the instance, so it should show up in the 284 // resulting object. 285 $itip = <<<ICS 286BEGIN:VCALENDAR 287VERSION:2.0 288METHOD:REPLY 289BEGIN:VEVENT 290ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher@example.org 291ORGANIZER:mailto:bar@example.org 292SEQUENCE:2 293RECURRENCE-ID:20140725T000000Z 294UID:foobar 295END:VEVENT 296END:VCALENDAR 297ICS; 298 299 $old = <<<ICS 300BEGIN:VCALENDAR 301VERSION:2.0 302BEGIN:VEVENT 303SEQUENCE:2 304UID:foobar 305RRULE:FREQ=DAILY 306DTSTART:20140724T000000Z 307ORGANIZER:mailto:bar@example.org 308END:VEVENT 309END:VCALENDAR 310ICS; 311 312 $expected = <<<ICS 313BEGIN:VCALENDAR 314VERSION:2.0 315BEGIN:VEVENT 316SEQUENCE:2 317UID:foobar 318RRULE:FREQ=DAILY 319DTSTART:20140724T000000Z 320ORGANIZER:mailto:bar@example.org 321END:VEVENT 322BEGIN:VEVENT 323SEQUENCE:2 324UID:foobar 325DTSTART:20140725T000000Z 326ORGANIZER:mailto:bar@example.org 327RECURRENCE-ID:20140725T000000Z 328ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher@example.org 329END:VEVENT 330END:VCALENDAR 331ICS; 332 333 $result = $this->process($itip, $old, $expected); 334 335 } 336 337 function testReplyNewExceptionNoMasterEvent() { 338 339 /** 340 * This iTip message would normally create a new exception, but the 341 * server is not able to create this new instance, because there's no 342 * master event to clone from. 343 * 344 * This test checks if the message is ignored. 345 */ 346 $itip = <<<ICS 347BEGIN:VCALENDAR 348VERSION:2.0 349METHOD:REPLY 350BEGIN:VEVENT 351ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher@example.org 352ORGANIZER:mailto:bar@example.org 353SEQUENCE:2 354RECURRENCE-ID:20140725T000000Z 355UID:foobar 356END:VEVENT 357END:VCALENDAR 358ICS; 359 360 $old = <<<ICS 361BEGIN:VCALENDAR 362VERSION:2.0 363BEGIN:VEVENT 364SEQUENCE:2 365UID:foobar 366RRULE:FREQ=DAILY 367DTSTART:20140724T000000Z 368RECURRENCE-ID:20140724T000000Z 369ORGANIZER:mailto:bar@example.org 370END:VEVENT 371END:VCALENDAR 372ICS; 373 374 $expected = null; 375 $result = $this->process($itip, $old, $expected); 376 377 } 378 379 /** 380 * @depends testReplyAccept 381 */ 382 function testReplyAcceptUpdateRSVP() { 383 384 $itip = <<<ICS 385BEGIN:VCALENDAR 386VERSION:2.0 387METHOD:REPLY 388BEGIN:VEVENT 389ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org 390ORGANIZER:mailto:bar@example.org 391SEQUENCE:2 392UID:foobar 393END:VEVENT 394END:VCALENDAR 395ICS; 396 397 $old = <<<ICS 398BEGIN:VCALENDAR 399VERSION:2.0 400BEGIN:VEVENT 401SEQUENCE:2 402UID:foobar 403ATTENDEE;RSVP=TRUE:mailto:foo@example.org 404ORGANIZER:mailto:bar@example.org 405END:VEVENT 406END:VCALENDAR 407ICS; 408 409 $expected = <<<ICS 410BEGIN:VCALENDAR 411VERSION:2.0 412BEGIN:VEVENT 413SEQUENCE:2 414UID:foobar 415ATTENDEE;PARTSTAT=ACCEPTED;SCHEDULE-STATUS=2.0:mailto:foo@example.org 416ORGANIZER:mailto:bar@example.org 417END:VEVENT 418END:VCALENDAR 419ICS; 420 421 $result = $this->process($itip, $old, $expected); 422 423 } 424 425} 426