BrokerAttendeeReplyTest.php 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. <?php
  2. namespace Sabre\VObject\ITip;
  3. class BrokerAttendeeReplyTest extends BrokerTester {
  4. function testAccepted() {
  5. $oldMessage = <<<ICS
  6. BEGIN:VCALENDAR
  7. VERSION:2.0
  8. BEGIN:VEVENT
  9. UID:foobar
  10. SUMMARY:B-day party
  11. SEQUENCE:1
  12. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  13. ATTENDEE;CN=One:mailto:one@example.org
  14. DTSTART:20140716T120000Z
  15. END:VEVENT
  16. END:VCALENDAR
  17. ICS;
  18. $newMessage = <<<ICS
  19. BEGIN:VCALENDAR
  20. VERSION:2.0
  21. BEGIN:VEVENT
  22. UID:foobar
  23. SUMMARY:B-day party
  24. SEQUENCE:1
  25. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  26. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  27. DTSTART:20140716T120000Z
  28. END:VEVENT
  29. END:VCALENDAR
  30. ICS;
  31. $version = \Sabre\VObject\Version::VERSION;
  32. $expected = array(
  33. array(
  34. 'uid' => 'foobar',
  35. 'method' => 'REPLY',
  36. 'component' => 'VEVENT',
  37. 'sender' => 'mailto:one@example.org',
  38. 'senderName' => 'One',
  39. 'recipient' => 'mailto:strunk@example.org',
  40. 'recipientName' => 'Strunk',
  41. 'message' => <<<ICS
  42. BEGIN:VCALENDAR
  43. VERSION:2.0
  44. PRODID:-//Sabre//Sabre VObject $version//EN
  45. CALSCALE:GREGORIAN
  46. METHOD:REPLY
  47. BEGIN:VEVENT
  48. UID:foobar
  49. SEQUENCE:1
  50. DTSTART:20140716T120000Z
  51. SUMMARY:B-day party
  52. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  53. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  54. END:VEVENT
  55. END:VCALENDAR
  56. ICS
  57. ),
  58. );
  59. $result = $this->parse($oldMessage, $newMessage, $expected);
  60. }
  61. function testRecurringReply() {
  62. $oldMessage = <<<ICS
  63. BEGIN:VCALENDAR
  64. VERSION:2.0
  65. BEGIN:VEVENT
  66. UID:foobar
  67. SEQUENCE:1
  68. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  69. ATTENDEE;CN=One:mailto:one@example.org
  70. DTSTART:20140724T120000Z
  71. SUMMARY:Daily sprint
  72. RRULE;FREQ=DAILY
  73. END:VEVENT
  74. END:VCALENDAR
  75. ICS;
  76. $newMessage = <<<ICS
  77. BEGIN:VCALENDAR
  78. VERSION:2.0
  79. BEGIN:VEVENT
  80. UID:foobar
  81. SEQUENCE:1
  82. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  83. ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one@example.org
  84. DTSTART:20140724T120000Z
  85. SUMMARY:Daily sprint
  86. END:VEVENT
  87. BEGIN:VEVENT
  88. UID:foobar
  89. SEQUENCE:1
  90. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  91. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  92. DTSTART:20140726T120000Z
  93. RECURRENCE-ID:20140726T120000Z
  94. END:VEVENT
  95. BEGIN:VEVENT
  96. UID:foobar
  97. SEQUENCE:1
  98. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  99. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  100. DTSTART:20140724T120000Z
  101. RECURRENCE-ID:20140724T120000Z
  102. END:VEVENT
  103. BEGIN:VEVENT
  104. UID:foobar
  105. SEQUENCE:1
  106. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  107. ATTENDEE;PARTSTAT=TENTATIVE;CN=One:mailto:one@example.org
  108. DTSTART:20140728T120000Z
  109. RECURRENCE-ID:20140728T120000Z
  110. END:VEVENT
  111. BEGIN:VEVENT
  112. UID:foobar
  113. SEQUENCE:1
  114. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  115. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  116. DTSTART:20140729T120000Z
  117. RECURRENCE-ID:20140729T120000Z
  118. END:VEVENT
  119. BEGIN:VEVENT
  120. UID:foobar
  121. SEQUENCE:1
  122. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  123. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  124. DTSTART:20140725T120000Z
  125. RECURRENCE-ID:20140725T120000Z
  126. END:VEVENT
  127. END:VCALENDAR
  128. ICS;
  129. $version = \Sabre\VObject\Version::VERSION;
  130. $expected = array(
  131. array(
  132. 'uid' => 'foobar',
  133. 'method' => 'REPLY',
  134. 'component' => 'VEVENT',
  135. 'sender' => 'mailto:one@example.org',
  136. 'senderName' => 'One',
  137. 'recipient' => 'mailto:strunk@example.org',
  138. 'recipientName' => 'Strunk',
  139. 'message' => <<<ICS
  140. BEGIN:VCALENDAR
  141. VERSION:2.0
  142. PRODID:-//Sabre//Sabre VObject $version//EN
  143. CALSCALE:GREGORIAN
  144. METHOD:REPLY
  145. BEGIN:VEVENT
  146. UID:foobar
  147. SEQUENCE:1
  148. DTSTART:20140726T120000Z
  149. SUMMARY:Daily sprint
  150. RECURRENCE-ID:20140726T120000Z
  151. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  152. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  153. END:VEVENT
  154. BEGIN:VEVENT
  155. UID:foobar
  156. SEQUENCE:1
  157. DTSTART:20140724T120000Z
  158. SUMMARY:Daily sprint
  159. RECURRENCE-ID:20140724T120000Z
  160. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  161. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  162. END:VEVENT
  163. BEGIN:VEVENT
  164. UID:foobar
  165. SEQUENCE:1
  166. DTSTART:20140728T120000Z
  167. SUMMARY:Daily sprint
  168. RECURRENCE-ID:20140728T120000Z
  169. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  170. ATTENDEE;PARTSTAT=TENTATIVE;CN=One:mailto:one@example.org
  171. END:VEVENT
  172. BEGIN:VEVENT
  173. UID:foobar
  174. SEQUENCE:1
  175. DTSTART:20140729T120000Z
  176. SUMMARY:Daily sprint
  177. RECURRENCE-ID:20140729T120000Z
  178. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  179. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  180. END:VEVENT
  181. BEGIN:VEVENT
  182. UID:foobar
  183. SEQUENCE:1
  184. DTSTART:20140725T120000Z
  185. SUMMARY:Daily sprint
  186. RECURRENCE-ID:20140725T120000Z
  187. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  188. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  189. END:VEVENT
  190. END:VCALENDAR
  191. ICS
  192. ),
  193. );
  194. $result = $this->parse($oldMessage, $newMessage, $expected);
  195. }
  196. function testRecurringAllDay() {
  197. $oldMessage = <<<ICS
  198. BEGIN:VCALENDAR
  199. VERSION:2.0
  200. BEGIN:VEVENT
  201. UID:foobar
  202. SEQUENCE:1
  203. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  204. ATTENDEE;CN=One:mailto:one@example.org
  205. DTSTART;VALUE=DATE:20140724
  206. RRULE;FREQ=DAILY
  207. END:VEVENT
  208. END:VCALENDAR
  209. ICS;
  210. $newMessage = <<<ICS
  211. BEGIN:VCALENDAR
  212. VERSION:2.0
  213. BEGIN:VEVENT
  214. UID:foobar
  215. SEQUENCE:1
  216. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  217. ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one@example.org
  218. DTSTART;VALUE=DATE:20140724
  219. END:VEVENT
  220. BEGIN:VEVENT
  221. UID:foobar
  222. SEQUENCE:1
  223. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  224. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  225. DTSTART;VALUE=DATE:20140726
  226. RECURRENCE-ID;VALUE=DATE:20140726
  227. END:VEVENT
  228. BEGIN:VEVENT
  229. UID:foobar
  230. SEQUENCE:1
  231. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  232. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  233. DTSTART;VALUE=DATE:20140724
  234. RECURRENCE-ID;VALUE=DATE:20140724
  235. END:VEVENT
  236. BEGIN:VEVENT
  237. UID:foobar
  238. SEQUENCE:1
  239. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  240. ATTENDEE;PARTSTAT=TENTATIVE;CN=One:mailto:one@example.org
  241. DTSTART;VALUE=DATE:20140728
  242. RECURRENCE-ID;VALUE=DATE:20140728
  243. END:VEVENT
  244. BEGIN:VEVENT
  245. UID:foobar
  246. SEQUENCE:1
  247. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  248. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  249. DTSTART;VALUE=DATE:20140729
  250. RECURRENCE-ID;VALUE=DATE:20140729
  251. END:VEVENT
  252. BEGIN:VEVENT
  253. UID:foobar
  254. SEQUENCE:1
  255. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  256. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  257. DTSTART;VALUE=DATE:20140725
  258. RECURRENCE-ID;VALUE=DATE:20140725
  259. END:VEVENT
  260. END:VCALENDAR
  261. ICS;
  262. $version = \Sabre\VObject\Version::VERSION;
  263. $expected = array(
  264. array(
  265. 'uid' => 'foobar',
  266. 'method' => 'REPLY',
  267. 'component' => 'VEVENT',
  268. 'sender' => 'mailto:one@example.org',
  269. 'senderName' => 'One',
  270. 'recipient' => 'mailto:strunk@example.org',
  271. 'recipientName' => 'Strunk',
  272. 'message' => <<<ICS
  273. BEGIN:VCALENDAR
  274. VERSION:2.0
  275. PRODID:-//Sabre//Sabre VObject $version//EN
  276. CALSCALE:GREGORIAN
  277. METHOD:REPLY
  278. BEGIN:VEVENT
  279. UID:foobar
  280. SEQUENCE:1
  281. DTSTART;VALUE=DATE:20140726
  282. RECURRENCE-ID;VALUE=DATE:20140726
  283. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  284. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  285. END:VEVENT
  286. BEGIN:VEVENT
  287. UID:foobar
  288. SEQUENCE:1
  289. DTSTART;VALUE=DATE:20140724
  290. RECURRENCE-ID;VALUE=DATE:20140724
  291. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  292. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  293. END:VEVENT
  294. BEGIN:VEVENT
  295. UID:foobar
  296. SEQUENCE:1
  297. DTSTART;VALUE=DATE:20140728
  298. RECURRENCE-ID;VALUE=DATE:20140728
  299. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  300. ATTENDEE;PARTSTAT=TENTATIVE;CN=One:mailto:one@example.org
  301. END:VEVENT
  302. BEGIN:VEVENT
  303. UID:foobar
  304. SEQUENCE:1
  305. DTSTART;VALUE=DATE:20140729
  306. RECURRENCE-ID;VALUE=DATE:20140729
  307. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  308. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  309. END:VEVENT
  310. BEGIN:VEVENT
  311. UID:foobar
  312. SEQUENCE:1
  313. DTSTART;VALUE=DATE:20140725
  314. RECURRENCE-ID;VALUE=DATE:20140725
  315. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  316. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  317. END:VEVENT
  318. END:VCALENDAR
  319. ICS
  320. ),
  321. );
  322. $result = $this->parse($oldMessage, $newMessage, $expected);
  323. }
  324. function testNoChange() {
  325. $oldMessage = <<<ICS
  326. BEGIN:VCALENDAR
  327. VERSION:2.0
  328. BEGIN:VEVENT
  329. UID:foobar
  330. SEQUENCE:1
  331. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  332. ATTENDEE;CN=One:mailto:one@example.org
  333. DTSTART:20140716T120000Z
  334. END:VEVENT
  335. END:VCALENDAR
  336. ICS;
  337. $newMessage = <<<ICS
  338. BEGIN:VCALENDAR
  339. VERSION:2.0
  340. BEGIN:VEVENT
  341. UID:foobar
  342. SEQUENCE:1
  343. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  344. ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one@example.org
  345. DTSTART:20140716T120000Z
  346. END:VEVENT
  347. END:VCALENDAR
  348. ICS;
  349. $expected = array();
  350. $result = $this->parse($oldMessage, $newMessage, $expected);
  351. }
  352. function testNoChangeForceSend() {
  353. $oldMessage = <<<ICS
  354. BEGIN:VCALENDAR
  355. VERSION:2.0
  356. BEGIN:VEVENT
  357. UID:foobar
  358. SEQUENCE:1
  359. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  360. ATTENDEE;CN=One:mailto:one@example.org
  361. DTSTART:20140716T120000Z
  362. END:VEVENT
  363. END:VCALENDAR
  364. ICS;
  365. $newMessage = <<<ICS
  366. BEGIN:VCALENDAR
  367. VERSION:2.0
  368. BEGIN:VEVENT
  369. UID:foobar
  370. SEQUENCE:1
  371. ORGANIZER;SCHEDULE-FORCE-SEND=REPLY;CN=Strunk:mailto:strunk@example.org
  372. ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one@example.org
  373. DTSTART:20140716T120000Z
  374. END:VEVENT
  375. END:VCALENDAR
  376. ICS;
  377. $version = \Sabre\VObject\Version::VERSION;
  378. $expected = array(
  379. array(
  380. 'uid' => 'foobar',
  381. 'method' => 'REPLY',
  382. 'component' => 'VEVENT',
  383. 'sender' => 'mailto:one@example.org',
  384. 'senderName' => 'One',
  385. 'recipient' => 'mailto:strunk@example.org',
  386. 'recipientName' => 'Strunk',
  387. 'message' => <<<ICS
  388. BEGIN:VCALENDAR
  389. VERSION:2.0
  390. PRODID:-//Sabre//Sabre VObject $version//EN
  391. CALSCALE:GREGORIAN
  392. METHOD:REPLY
  393. BEGIN:VEVENT
  394. UID:foobar
  395. SEQUENCE:1
  396. DTSTART:20140716T120000Z
  397. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  398. ATTENDEE;PARTSTAT=NEEDS-ACTION;CN=One:mailto:one@example.org
  399. END:VEVENT
  400. END:VCALENDAR
  401. ICS
  402. )
  403. );
  404. $result = $this->parse($oldMessage, $newMessage, $expected);
  405. }
  406. function testNoRelevantAttendee() {
  407. $oldMessage = <<<ICS
  408. BEGIN:VCALENDAR
  409. VERSION:2.0
  410. BEGIN:VEVENT
  411. UID:foobar
  412. SEQUENCE:1
  413. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  414. ATTENDEE;CN=Two:mailto:two@example.org
  415. DTSTART:20140716T120000Z
  416. END:VEVENT
  417. END:VCALENDAR
  418. ICS;
  419. $newMessage = <<<ICS
  420. BEGIN:VCALENDAR
  421. VERSION:2.0
  422. BEGIN:VEVENT
  423. UID:foobar
  424. SEQUENCE:1
  425. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  426. ATTENDEE;PARTSTAT=ACCEPTED;CN=Two:mailto:two@example.org
  427. DTSTART:20140716T120000Z
  428. END:VEVENT
  429. END:VCALENDAR
  430. ICS;
  431. $expected = array();
  432. $result = $this->parse($oldMessage, $newMessage, $expected);
  433. }
  434. /**
  435. * In this test, an event exists in an attendees calendar. The event
  436. * is recurring, and the attendee deletes 1 instance of the event.
  437. * This instance shows up in EXDATE
  438. *
  439. * This should automatically generate a DECLINED message for that
  440. * specific instance.
  441. */
  442. function testCreateReplyByException() {
  443. $oldMessage = <<<ICS
  444. BEGIN:VCALENDAR
  445. VERSION:2.0
  446. BEGIN:VEVENT
  447. UID:foobar
  448. SEQUENCE:1
  449. DTSTART:20140811T200000Z
  450. RRULE:FREQ=WEEKLY
  451. ORGANIZER:mailto:organizer@example.org
  452. ATTENDEE:mailto:one@example.org
  453. END:VEVENT
  454. END:VCALENDAR
  455. ICS;
  456. $newMessage = <<<ICS
  457. BEGIN:VCALENDAR
  458. VERSION:2.0
  459. BEGIN:VEVENT
  460. UID:foobar
  461. SEQUENCE:1
  462. DTSTART:20140811T200000Z
  463. RRULE:FREQ=WEEKLY
  464. ORGANIZER:mailto:organizer@example.org
  465. ATTENDEE:mailto:one@example.org
  466. EXDATE:20140818T200000Z
  467. END:VEVENT
  468. END:VCALENDAR
  469. ICS;
  470. $version = \Sabre\VObject\Version::VERSION;
  471. $expected = array(
  472. array(
  473. 'uid' => 'foobar',
  474. 'method' => 'REPLY',
  475. 'component' => 'VEVENT',
  476. 'sender' => 'mailto:one@example.org',
  477. 'senderName' => null,
  478. 'recipient' => 'mailto:organizer@example.org',
  479. 'recipientName' => null,
  480. 'message' => <<<ICS
  481. BEGIN:VCALENDAR
  482. VERSION:2.0
  483. PRODID:-//Sabre//Sabre VObject $version//EN
  484. CALSCALE:GREGORIAN
  485. METHOD:REPLY
  486. BEGIN:VEVENT
  487. UID:foobar
  488. SEQUENCE:1
  489. DTSTART:20140818T200000Z
  490. RECURRENCE-ID:20140818T200000Z
  491. ORGANIZER:mailto:organizer@example.org
  492. ATTENDEE;PARTSTAT=DECLINED:mailto:one@example.org
  493. END:VEVENT
  494. END:VCALENDAR
  495. ICS
  496. ),
  497. );
  498. $result = $this->parse($oldMessage, $newMessage, $expected);
  499. }
  500. /**
  501. * This test is identical to the last, but now we're working with
  502. * timezones.
  503. *
  504. * @depends testCreateReplyByException
  505. */
  506. function testCreateReplyByExceptionTz() {
  507. $oldMessage = <<<ICS
  508. BEGIN:VCALENDAR
  509. VERSION:2.0
  510. BEGIN:VEVENT
  511. UID:foobar
  512. SEQUENCE:1
  513. DTSTART;TZID=America/Toronto:20140811T200000
  514. RRULE:FREQ=WEEKLY
  515. ORGANIZER:mailto:organizer@example.org
  516. ATTENDEE:mailto:one@example.org
  517. END:VEVENT
  518. END:VCALENDAR
  519. ICS;
  520. $newMessage = <<<ICS
  521. BEGIN:VCALENDAR
  522. VERSION:2.0
  523. BEGIN:VEVENT
  524. UID:foobar
  525. SEQUENCE:1
  526. DTSTART;TZID=America/Toronto:20140811T200000
  527. RRULE:FREQ=WEEKLY
  528. ORGANIZER:mailto:organizer@example.org
  529. ATTENDEE:mailto:one@example.org
  530. EXDATE;TZID=America/Toronto:20140818T200000
  531. END:VEVENT
  532. END:VCALENDAR
  533. ICS;
  534. $version = \Sabre\VObject\Version::VERSION;
  535. $expected = array(
  536. array(
  537. 'uid' => 'foobar',
  538. 'method' => 'REPLY',
  539. 'component' => 'VEVENT',
  540. 'sender' => 'mailto:one@example.org',
  541. 'senderName' => null,
  542. 'recipient' => 'mailto:organizer@example.org',
  543. 'recipientName' => null,
  544. 'message' => <<<ICS
  545. BEGIN:VCALENDAR
  546. VERSION:2.0
  547. PRODID:-//Sabre//Sabre VObject $version//EN
  548. CALSCALE:GREGORIAN
  549. METHOD:REPLY
  550. BEGIN:VEVENT
  551. UID:foobar
  552. SEQUENCE:1
  553. DTSTART;TZID=America/Toronto:20140818T200000
  554. RECURRENCE-ID;TZID=America/Toronto:20140818T200000
  555. ORGANIZER:mailto:organizer@example.org
  556. ATTENDEE;PARTSTAT=DECLINED:mailto:one@example.org
  557. END:VEVENT
  558. END:VCALENDAR
  559. ICS
  560. ),
  561. );
  562. $result = $this->parse($oldMessage, $newMessage, $expected);
  563. }
  564. /**
  565. * @depends testCreateReplyByException
  566. */
  567. function testCreateReplyByExceptionAllDay() {
  568. $oldMessage = <<<ICS
  569. BEGIN:VCALENDAR
  570. VERSION:2.0
  571. BEGIN:VEVENT
  572. SUMMARY:Weekly meeting
  573. UID:foobar
  574. SEQUENCE:1
  575. DTSTART;VALUE=DATE:20140811
  576. RRULE:FREQ=WEEKLY
  577. ORGANIZER:mailto:organizer@example.org
  578. ATTENDEE:mailto:one@example.org
  579. END:VEVENT
  580. END:VCALENDAR
  581. ICS;
  582. $newMessage = <<<ICS
  583. BEGIN:VCALENDAR
  584. VERSION:2.0
  585. BEGIN:VEVENT
  586. SUMMARY:Weekly meeting
  587. UID:foobar
  588. SEQUENCE:1
  589. DTSTART;VALUE=DATE:20140811
  590. RRULE:FREQ=WEEKLY
  591. ORGANIZER:mailto:organizer@example.org
  592. ATTENDEE:mailto:one@example.org
  593. EXDATE;VALUE=DATE:20140818
  594. END:VEVENT
  595. END:VCALENDAR
  596. ICS;
  597. $version = \Sabre\VObject\Version::VERSION;
  598. $expected = array(
  599. array(
  600. 'uid' => 'foobar',
  601. 'method' => 'REPLY',
  602. 'component' => 'VEVENT',
  603. 'sender' => 'mailto:one@example.org',
  604. 'senderName' => null,
  605. 'recipient' => 'mailto:organizer@example.org',
  606. 'recipientName' => null,
  607. 'message' => <<<ICS
  608. BEGIN:VCALENDAR
  609. VERSION:2.0
  610. PRODID:-//Sabre//Sabre VObject $version//EN
  611. CALSCALE:GREGORIAN
  612. METHOD:REPLY
  613. BEGIN:VEVENT
  614. UID:foobar
  615. SEQUENCE:1
  616. DTSTART;VALUE=DATE:20140818
  617. SUMMARY:Weekly meeting
  618. RECURRENCE-ID;VALUE=DATE:20140818
  619. ORGANIZER:mailto:organizer@example.org
  620. ATTENDEE;PARTSTAT=DECLINED:mailto:one@example.org
  621. END:VEVENT
  622. END:VCALENDAR
  623. ICS
  624. ),
  625. );
  626. $result = $this->parse($oldMessage, $newMessage, $expected);
  627. }
  628. function testDeclined() {
  629. $oldMessage = <<<ICS
  630. BEGIN:VCALENDAR
  631. VERSION:2.0
  632. BEGIN:VEVENT
  633. UID:foobar
  634. SEQUENCE:1
  635. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  636. ATTENDEE;CN=One:mailto:one@example.org
  637. DTSTART:20140716T120000Z
  638. END:VEVENT
  639. END:VCALENDAR
  640. ICS;
  641. $newMessage = <<<ICS
  642. BEGIN:VCALENDAR
  643. VERSION:2.0
  644. BEGIN:VEVENT
  645. UID:foobar
  646. SEQUENCE:1
  647. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  648. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  649. DTSTART:20140716T120000Z
  650. END:VEVENT
  651. END:VCALENDAR
  652. ICS;
  653. $version = \Sabre\VObject\Version::VERSION;
  654. $expected = array(
  655. array(
  656. 'uid' => 'foobar',
  657. 'method' => 'REPLY',
  658. 'component' => 'VEVENT',
  659. 'sender' => 'mailto:one@example.org',
  660. 'senderName' => 'One',
  661. 'recipient' => 'mailto:strunk@example.org',
  662. 'recipientName' => 'Strunk',
  663. 'message' => <<<ICS
  664. BEGIN:VCALENDAR
  665. VERSION:2.0
  666. PRODID:-//Sabre//Sabre VObject $version//EN
  667. CALSCALE:GREGORIAN
  668. METHOD:REPLY
  669. BEGIN:VEVENT
  670. UID:foobar
  671. SEQUENCE:1
  672. DTSTART:20140716T120000Z
  673. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  674. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  675. END:VEVENT
  676. END:VCALENDAR
  677. ICS
  678. ),
  679. );
  680. $result = $this->parse($oldMessage, $newMessage, $expected);
  681. }
  682. function testDeclinedCancelledEvent() {
  683. $oldMessage = <<<ICS
  684. BEGIN:VCALENDAR
  685. VERSION:2.0
  686. BEGIN:VEVENT
  687. STATUS:CANCELLED
  688. UID:foobar
  689. SEQUENCE:1
  690. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  691. ATTENDEE;CN=One:mailto:one@example.org
  692. DTSTART:20140716T120000Z
  693. END:VEVENT
  694. END:VCALENDAR
  695. ICS;
  696. $newMessage = <<<ICS
  697. BEGIN:VCALENDAR
  698. VERSION:2.0
  699. BEGIN:VEVENT
  700. STATUS:CANCELLED
  701. UID:foobar
  702. SEQUENCE:1
  703. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  704. ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
  705. DTSTART:20140716T120000Z
  706. END:VEVENT
  707. END:VCALENDAR
  708. ICS;
  709. $version = \Sabre\VObject\Version::VERSION;
  710. $expected = array();
  711. $result = $this->parse($oldMessage, $newMessage, $expected);
  712. }
  713. /**
  714. * In this test, a new exception is created by an attendee as well.
  715. *
  716. * Except in this case, there was already an overridden event, and the
  717. * overridden event was marked as cancelled by the attendee.
  718. *
  719. * For any other attendence status, the new status would have been
  720. * declined, but for this, no message should we sent.
  721. */
  722. function testDontCreateReplyWhenEventWasDeclined() {
  723. $oldMessage = <<<ICS
  724. BEGIN:VCALENDAR
  725. VERSION:2.0
  726. BEGIN:VEVENT
  727. UID:foobar
  728. SEQUENCE:1
  729. DTSTART:20140811T200000Z
  730. RRULE:FREQ=WEEKLY
  731. ORGANIZER:mailto:organizer@example.org
  732. ATTENDEE:mailto:one@example.org
  733. END:VEVENT
  734. BEGIN:VEVENT
  735. RECURRENCE-ID:20140818T200000Z
  736. UID:foobar
  737. SEQUENCE:1
  738. DTSTART:20140818T200000Z
  739. RRULE:FREQ=WEEKLY
  740. ORGANIZER:mailto:organizer@example.org
  741. ATTENDEE;PARTSTAT=DECLINED:mailto:one@example.org
  742. END:VEVENT
  743. END:VCALENDAR
  744. ICS;
  745. $newMessage = <<<ICS
  746. BEGIN:VCALENDAR
  747. VERSION:2.0
  748. BEGIN:VEVENT
  749. UID:foobar
  750. SEQUENCE:1
  751. DTSTART:20140811T200000Z
  752. RRULE:FREQ=WEEKLY
  753. ORGANIZER:mailto:organizer@example.org
  754. ATTENDEE:mailto:one@example.org
  755. EXDATE:20140818T200000Z
  756. END:VEVENT
  757. END:VCALENDAR
  758. ICS;
  759. $version = \Sabre\VObject\Version::VERSION;
  760. $expected = array();
  761. $result = $this->parse($oldMessage, $newMessage, $expected);
  762. }
  763. function testScheduleAgentOnOrganizer() {
  764. $oldMessage = <<<ICS
  765. BEGIN:VCALENDAR
  766. VERSION:2.0
  767. BEGIN:VEVENT
  768. UID:foobar
  769. SEQUENCE:1
  770. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  771. ATTENDEE;CN=One:mailto:one@example.org
  772. DTSTART:20140716T120000Z
  773. END:VEVENT
  774. END:VCALENDAR
  775. ICS;
  776. $newMessage = <<<ICS
  777. BEGIN:VCALENDAR
  778. VERSION:2.0
  779. BEGIN:VEVENT
  780. UID:foobar
  781. SEQUENCE:1
  782. ORGANIZER;SCHEDULE-AGENT=CLIENT;CN=Strunk:mailto:strunk@example.org
  783. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  784. DTSTART:20140716T120000Z
  785. END:VEVENT
  786. END:VCALENDAR
  787. ICS;
  788. $version = \Sabre\VObject\Version::VERSION;
  789. $expected = array();
  790. $result = $this->parse($oldMessage, $newMessage, $expected);
  791. }
  792. function testAcceptedAllDay() {
  793. $oldMessage = <<<ICS
  794. BEGIN:VCALENDAR
  795. VERSION:2.0
  796. BEGIN:VEVENT
  797. UID:foobar
  798. SEQUENCE:1
  799. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  800. ATTENDEE;CN=One:mailto:one@example.org
  801. DTSTART;VALUE=DATE:20140716
  802. END:VEVENT
  803. END:VCALENDAR
  804. ICS;
  805. $newMessage = <<<ICS
  806. BEGIN:VCALENDAR
  807. VERSION:2.0
  808. BEGIN:VEVENT
  809. UID:foobar
  810. SEQUENCE:1
  811. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  812. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  813. DTSTART;VALUE=DATE:20140716
  814. END:VEVENT
  815. END:VCALENDAR
  816. ICS;
  817. $version = \Sabre\VObject\Version::VERSION;
  818. $expected = array(
  819. array(
  820. 'uid' => 'foobar',
  821. 'method' => 'REPLY',
  822. 'component' => 'VEVENT',
  823. 'sender' => 'mailto:one@example.org',
  824. 'senderName' => 'One',
  825. 'recipient' => 'mailto:strunk@example.org',
  826. 'recipientName' => 'Strunk',
  827. 'message' => <<<ICS
  828. BEGIN:VCALENDAR
  829. VERSION:2.0
  830. PRODID:-//Sabre//Sabre VObject $version//EN
  831. CALSCALE:GREGORIAN
  832. METHOD:REPLY
  833. BEGIN:VEVENT
  834. UID:foobar
  835. SEQUENCE:1
  836. DTSTART;VALUE=DATE:20140716
  837. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  838. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  839. END:VEVENT
  840. END:VCALENDAR
  841. ICS
  842. ),
  843. );
  844. $result = $this->parse($oldMessage, $newMessage, $expected);
  845. }
  846. /**
  847. * This function tests an attendee updating their status to an event where
  848. * they don't have the master event of.
  849. *
  850. * This is possible in cases an organizer created a recurring event, and
  851. * invited an attendee for one instance of the event.
  852. */
  853. function testReplyNoMasterEvent() {
  854. $oldMessage = <<<ICS
  855. BEGIN:VCALENDAR
  856. VERSION:2.0
  857. BEGIN:VEVENT
  858. UID:foobar
  859. SEQUENCE:1
  860. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  861. ATTENDEE;CN=One:mailto:one@example.org
  862. RECURRENCE-ID:20140724T120000Z
  863. DTSTART:20140724T120000Z
  864. SUMMARY:Daily sprint
  865. END:VEVENT
  866. END:VCALENDAR
  867. ICS;
  868. $newMessage = <<<ICS
  869. BEGIN:VCALENDAR
  870. VERSION:2.0
  871. BEGIN:VEVENT
  872. UID:foobar
  873. SEQUENCE:1
  874. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  875. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  876. RECURRENCE-ID:20140724T120000Z
  877. DTSTART:20140724T120000Z
  878. SUMMARY:Daily sprint
  879. END:VEVENT
  880. END:VCALENDAR
  881. ICS;
  882. $version = \Sabre\VObject\Version::VERSION;
  883. $expected = array(
  884. array(
  885. 'uid' => 'foobar',
  886. 'method' => 'REPLY',
  887. 'component' => 'VEVENT',
  888. 'sender' => 'mailto:one@example.org',
  889. 'senderName' => 'One',
  890. 'recipient' => 'mailto:strunk@example.org',
  891. 'recipientName' => 'Strunk',
  892. 'message' => <<<ICS
  893. BEGIN:VCALENDAR
  894. VERSION:2.0
  895. CALSCALE:GREGORIAN
  896. METHOD:REPLY
  897. BEGIN:VEVENT
  898. UID:foobar
  899. SEQUENCE:1
  900. DTSTART:20140724T120000Z
  901. SUMMARY:Daily sprint
  902. RECURRENCE-ID:20140724T120000Z
  903. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  904. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  905. END:VEVENT
  906. END:VCALENDAR
  907. ICS
  908. ),
  909. );
  910. $result = $this->parse($oldMessage, $newMessage, $expected);
  911. }
  912. /**
  913. * A party crasher is an attendee that accepted an event, but was not in
  914. * any original invite.
  915. *
  916. * @depends testAccepted
  917. */
  918. function testPartyCrasher() {
  919. $oldMessage = <<<ICS
  920. BEGIN:VCALENDAR
  921. VERSION:2.0
  922. BEGIN:VEVENT
  923. UID:foobar
  924. SUMMARY:B-day party
  925. SEQUENCE:1
  926. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  927. DTSTART:20140716T120000Z
  928. RRULE:FREQ=DAILY
  929. END:VEVENT
  930. BEGIN:VEVENT
  931. UID:foobar
  932. RECURRENCE-ID:20140717T120000Z
  933. SUMMARY:B-day party
  934. SEQUENCE:1
  935. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  936. DTSTART:20140717T120000Z
  937. RRULE:FREQ=DAILY
  938. END:VEVENT
  939. END:VCALENDAR
  940. ICS;
  941. $newMessage = <<<ICS
  942. BEGIN:VCALENDAR
  943. VERSION:2.0
  944. BEGIN:VEVENT
  945. UID:foobar
  946. SUMMARY:B-day party
  947. SEQUENCE:1
  948. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  949. DTSTART:20140716T120000Z
  950. RRULE:FREQ=DAILY
  951. END:VEVENT
  952. BEGIN:VEVENT
  953. UID:foobar
  954. RECURRENCE-ID:20140717T120000Z
  955. SUMMARY:B-day party
  956. SEQUENCE:1
  957. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  958. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  959. DTSTART:20140717T120000Z
  960. RRULE:FREQ=DAILY
  961. END:VEVENT
  962. END:VCALENDAR
  963. ICS;
  964. $version = \Sabre\VObject\Version::VERSION;
  965. $expected = array(
  966. array(
  967. 'uid' => 'foobar',
  968. 'method' => 'REPLY',
  969. 'component' => 'VEVENT',
  970. 'sender' => 'mailto:one@example.org',
  971. 'senderName' => 'One',
  972. 'recipient' => 'mailto:strunk@example.org',
  973. 'recipientName' => 'Strunk',
  974. 'message' => <<<ICS
  975. BEGIN:VCALENDAR
  976. VERSION:2.0
  977. CALSCALE:GREGORIAN
  978. METHOD:REPLY
  979. BEGIN:VEVENT
  980. UID:foobar
  981. SEQUENCE:1
  982. DTSTART:20140717T120000Z
  983. SUMMARY:B-day party
  984. RECURRENCE-ID:20140717T120000Z
  985. ORGANIZER;CN=Strunk:mailto:strunk@example.org
  986. ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one@example.org
  987. END:VEVENT
  988. END:VCALENDAR
  989. ICS
  990. ),
  991. );
  992. $result = $this->parse($oldMessage, $newMessage, $expected);
  993. }
  994. }