BrokerProcessReplyTest.php 9.2 KB

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