BrokerDeleteEventTest.php 7.5 KB

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