CalDavBackendTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Thomas Citharel <tcit@tcit.fr>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCA\DAV\Tests\unit\CalDAV;
  25. use DateTime;
  26. use DateTimeZone;
  27. use OCA\DAV\CalDAV\CalDavBackend;
  28. use OCA\DAV\CalDAV\Calendar;
  29. use OCP\IL10N;
  30. use Sabre\DAV\PropPatch;
  31. use Sabre\DAV\Xml\Property\Href;
  32. use Sabre\DAVACL\IACL;
  33. /**
  34. * Class CalDavBackendTest
  35. *
  36. * @group DB
  37. *
  38. * @package OCA\DAV\Tests\unit\CalDAV
  39. */
  40. class CalDavBackendTest extends AbstractCalDavBackendTest {
  41. public function testCalendarOperations() {
  42. $calendarId = $this->createTestCalendar();
  43. // update it's display name
  44. $patch = new PropPatch([
  45. '{DAV:}displayname' => 'Unit test',
  46. '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar used for unit testing'
  47. ]);
  48. $this->dispatcher->expects($this->at(0))
  49. ->method('dispatch')
  50. ->with('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar');
  51. $this->backend->updateCalendar($calendarId, $patch);
  52. $patch->commit();
  53. $this->assertEquals(1, $this->backend->getCalendarsForUserCount(self::UNIT_TEST_USER));
  54. $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
  55. $this->assertCount(1, $calendars);
  56. $this->assertEquals('Unit test', $calendars[0]['{DAV:}displayname']);
  57. $this->assertEquals('Calendar used for unit testing', $calendars[0]['{urn:ietf:params:xml:ns:caldav}calendar-description']);
  58. // delete the address book
  59. $this->dispatcher->expects($this->at(0))
  60. ->method('dispatch')
  61. ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar');
  62. $this->backend->deleteCalendar($calendars[0]['id']);
  63. $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
  64. $this->assertCount(0, $calendars);
  65. }
  66. public function providesSharingData() {
  67. return [
  68. [true, true, true, false, [
  69. [
  70. 'href' => 'principal:' . self::UNIT_TEST_USER1,
  71. 'readOnly' => false
  72. ],
  73. [
  74. 'href' => 'principal:' . self::UNIT_TEST_GROUP,
  75. 'readOnly' => true
  76. ]
  77. ]],
  78. [true, true, true, false, [
  79. [
  80. 'href' => 'principal:' . self::UNIT_TEST_GROUP,
  81. 'readOnly' => true,
  82. ],
  83. [
  84. 'href' => 'principal:' . self::UNIT_TEST_GROUP2,
  85. 'readOnly' => false,
  86. ],
  87. ]],
  88. [true, true, true, true, [
  89. [
  90. 'href' => 'principal:' . self::UNIT_TEST_GROUP,
  91. 'readOnly' => false,
  92. ],
  93. [
  94. 'href' => 'principal:' . self::UNIT_TEST_GROUP2,
  95. 'readOnly' => true,
  96. ],
  97. ]],
  98. [true, false, false, false, [
  99. [
  100. 'href' => 'principal:' . self::UNIT_TEST_USER1,
  101. 'readOnly' => true
  102. ],
  103. ]],
  104. ];
  105. }
  106. /**
  107. * @dataProvider providesSharingData
  108. */
  109. public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead, $groupCanWrite, $add) {
  110. /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject $l10n */
  111. $l10n = $this->createMock(IL10N::class);
  112. $l10n
  113. ->expects($this->any())
  114. ->method('t')
  115. ->will($this->returnCallback(function ($text, $parameters = array()) {
  116. return vsprintf($text, $parameters);
  117. }));
  118. $calendarId = $this->createTestCalendar();
  119. $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
  120. $this->assertCount(1, $calendars);
  121. $calendar = new Calendar($this->backend, $calendars[0], $l10n);
  122. $this->dispatcher->expects($this->at(0))
  123. ->method('dispatch')
  124. ->with('\OCA\DAV\CalDAV\CalDavBackend::updateShares');
  125. $this->backend->updateShares($calendar, $add, []);
  126. $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER1);
  127. $this->assertCount(1, $calendars);
  128. $calendar = new Calendar($this->backend, $calendars[0], $l10n);
  129. $acl = $calendar->getACL();
  130. $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl);
  131. $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl);
  132. $this->assertAccess($userCanRead, self::UNIT_TEST_USER1, '{DAV:}read', $acl);
  133. $this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl);
  134. $this->assertAccess($groupCanRead, self::UNIT_TEST_GROUP, '{DAV:}read', $acl);
  135. $this->assertAccess($groupCanWrite, self::UNIT_TEST_GROUP, '{DAV:}write', $acl);
  136. $this->assertEquals(self::UNIT_TEST_USER, $calendar->getOwner());
  137. // test acls on the child
  138. $uri = static::getUniqueID('calobj');
  139. $calData = <<<'EOD'
  140. BEGIN:VCALENDAR
  141. VERSION:2.0
  142. PRODID:ownCloud Calendar
  143. BEGIN:VEVENT
  144. CREATED;VALUE=DATE-TIME:20130910T125139Z
  145. UID:47d15e3ec8
  146. LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
  147. DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
  148. SUMMARY:Test Event
  149. DTSTART;VALUE=DATE-TIME:20130912T130000Z
  150. DTEND;VALUE=DATE-TIME:20130912T140000Z
  151. CLASS:PUBLIC
  152. END:VEVENT
  153. END:VCALENDAR
  154. EOD;
  155. $this->dispatcher->expects($this->at(0))
  156. ->method('dispatch')
  157. ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
  158. $this->backend->createCalendarObject($calendarId, $uri, $calData);
  159. /** @var IACL $child */
  160. $child = $calendar->getChild($uri);
  161. $acl = $child->getACL();
  162. $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl);
  163. $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl);
  164. $this->assertAccess($userCanRead, self::UNIT_TEST_USER1, '{DAV:}read', $acl);
  165. $this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl);
  166. $this->assertAccess($groupCanRead, self::UNIT_TEST_GROUP, '{DAV:}read', $acl);
  167. $this->assertAccess($groupCanWrite, self::UNIT_TEST_GROUP, '{DAV:}write', $acl);
  168. // delete the address book
  169. $this->dispatcher->expects($this->at(0))
  170. ->method('dispatch')
  171. ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar');
  172. $this->backend->deleteCalendar($calendars[0]['id']);
  173. $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
  174. $this->assertCount(0, $calendars);
  175. }
  176. public function testCalendarObjectsOperations() {
  177. $calendarId = $this->createTestCalendar();
  178. // create a card
  179. $uri = static::getUniqueID('calobj');
  180. $calData = <<<'EOD'
  181. BEGIN:VCALENDAR
  182. VERSION:2.0
  183. PRODID:ownCloud Calendar
  184. BEGIN:VEVENT
  185. CREATED;VALUE=DATE-TIME:20130910T125139Z
  186. UID:47d15e3ec8
  187. LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
  188. DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
  189. SUMMARY:Test Event
  190. DTSTART;VALUE=DATE-TIME:20130912T130000Z
  191. DTEND;VALUE=DATE-TIME:20130912T140000Z
  192. CLASS:PUBLIC
  193. END:VEVENT
  194. END:VCALENDAR
  195. EOD;
  196. $this->dispatcher->expects($this->at(0))
  197. ->method('dispatch')
  198. ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
  199. $this->backend->createCalendarObject($calendarId, $uri, $calData);
  200. // get all the cards
  201. $calendarObjects = $this->backend->getCalendarObjects($calendarId);
  202. $this->assertCount(1, $calendarObjects);
  203. $this->assertEquals($calendarId, $calendarObjects[0]['calendarid']);
  204. $this->assertArrayHasKey('classification', $calendarObjects[0]);
  205. // get the cards
  206. $calendarObject = $this->backend->getCalendarObject($calendarId, $uri);
  207. $this->assertNotNull($calendarObject);
  208. $this->assertArrayHasKey('id', $calendarObject);
  209. $this->assertArrayHasKey('uri', $calendarObject);
  210. $this->assertArrayHasKey('lastmodified', $calendarObject);
  211. $this->assertArrayHasKey('etag', $calendarObject);
  212. $this->assertArrayHasKey('size', $calendarObject);
  213. $this->assertArrayHasKey('classification', $calendarObject);
  214. $this->assertEquals($calData, $calendarObject['calendardata']);
  215. // update the card
  216. $calData = <<<'EOD'
  217. BEGIN:VCALENDAR
  218. VERSION:2.0
  219. PRODID:ownCloud Calendar
  220. BEGIN:VEVENT
  221. CREATED;VALUE=DATE-TIME:20130910T125139Z
  222. UID:47d15e3ec8
  223. LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
  224. DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
  225. SUMMARY:Test Event
  226. DTSTART;VALUE=DATE-TIME:20130912T130000Z
  227. DTEND;VALUE=DATE-TIME:20130912T140000Z
  228. END:VEVENT
  229. END:VCALENDAR
  230. EOD;
  231. $this->dispatcher->expects($this->at(0))
  232. ->method('dispatch')
  233. ->with('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject');
  234. $this->backend->updateCalendarObject($calendarId, $uri, $calData);
  235. $calendarObject = $this->backend->getCalendarObject($calendarId, $uri);
  236. $this->assertEquals($calData, $calendarObject['calendardata']);
  237. // delete the card
  238. $this->dispatcher->expects($this->at(0))
  239. ->method('dispatch')
  240. ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
  241. $this->backend->deleteCalendarObject($calendarId, $uri);
  242. $calendarObjects = $this->backend->getCalendarObjects($calendarId);
  243. $this->assertCount(0, $calendarObjects);
  244. }
  245. public function testMultiCalendarObjects() {
  246. $calendarId = $this->createTestCalendar();
  247. // create an event
  248. $calData = <<<'EOD'
  249. BEGIN:VCALENDAR
  250. VERSION:2.0
  251. PRODID:ownCloud Calendar
  252. BEGIN:VEVENT
  253. CREATED;VALUE=DATE-TIME:20130910T125139Z
  254. UID:47d15e3ec8
  255. LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
  256. DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
  257. SUMMARY:Test Event
  258. DTSTART;VALUE=DATE-TIME:20130912T130000Z
  259. DTEND;VALUE=DATE-TIME:20130912T140000Z
  260. CLASS:PUBLIC
  261. END:VEVENT
  262. END:VCALENDAR
  263. EOD;
  264. $uri0 = static::getUniqueID('card');
  265. $this->dispatcher->expects($this->at(0))
  266. ->method('dispatch')
  267. ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
  268. $this->backend->createCalendarObject($calendarId, $uri0, $calData);
  269. $uri1 = static::getUniqueID('card');
  270. $this->dispatcher->expects($this->at(0))
  271. ->method('dispatch')
  272. ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
  273. $this->backend->createCalendarObject($calendarId, $uri1, $calData);
  274. $uri2 = static::getUniqueID('card');
  275. $this->dispatcher->expects($this->at(0))
  276. ->method('dispatch')
  277. ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
  278. $this->backend->createCalendarObject($calendarId, $uri2, $calData);
  279. // get all the cards
  280. $calendarObjects = $this->backend->getCalendarObjects($calendarId);
  281. $this->assertCount(3, $calendarObjects);
  282. // get the cards
  283. $calendarObjects = $this->backend->getMultipleCalendarObjects($calendarId, [$uri1, $uri2]);
  284. $this->assertCount(2, $calendarObjects);
  285. foreach($calendarObjects as $card) {
  286. $this->assertArrayHasKey('id', $card);
  287. $this->assertArrayHasKey('uri', $card);
  288. $this->assertArrayHasKey('lastmodified', $card);
  289. $this->assertArrayHasKey('etag', $card);
  290. $this->assertArrayHasKey('size', $card);
  291. $this->assertArrayHasKey('classification', $card);
  292. $this->assertEquals($calData, $card['calendardata']);
  293. }
  294. // delete the card
  295. $this->dispatcher->expects($this->at(0))
  296. ->method('dispatch')
  297. ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
  298. $this->backend->deleteCalendarObject($calendarId, $uri0);
  299. $this->dispatcher->expects($this->at(0))
  300. ->method('dispatch')
  301. ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
  302. $this->backend->deleteCalendarObject($calendarId, $uri1);
  303. $this->dispatcher->expects($this->at(0))
  304. ->method('dispatch')
  305. ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
  306. $this->backend->deleteCalendarObject($calendarId, $uri2);
  307. $calendarObjects = $this->backend->getCalendarObjects($calendarId);
  308. $this->assertCount(0, $calendarObjects);
  309. }
  310. /**
  311. * @dataProvider providesCalendarQueryParameters
  312. */
  313. public function testCalendarQuery($expectedEventsInResult, $propFilters, $compFilter) {
  314. $calendarId = $this->createTestCalendar();
  315. $events = [];
  316. $events[0] = $this->createEvent($calendarId, '20130912T130000Z', '20130912T140000Z');
  317. $events[1] = $this->createEvent($calendarId, '20130912T150000Z', '20130912T170000Z');
  318. $events[2] = $this->createEvent($calendarId, '20130912T173000Z', '20130912T220000Z');
  319. $events[3] = $this->createEvent($calendarId, '21130912T130000Z', '22130912T130000Z');
  320. $result = $this->backend->calendarQuery($calendarId, [
  321. 'name' => '',
  322. 'prop-filters' => $propFilters,
  323. 'comp-filters' => $compFilter
  324. ]);
  325. $expectedEventsInResult = array_map(function($index) use($events) {
  326. return $events[$index];
  327. }, $expectedEventsInResult);
  328. $this->assertEquals($expectedEventsInResult, $result, '', 0.0, 10, true);
  329. }
  330. public function testGetCalendarObjectByUID() {
  331. $calendarId = $this->createTestCalendar();
  332. $this->createEvent($calendarId, '20130912T130000Z', '20130912T140000Z');
  333. $co = $this->backend->getCalendarObjectByUID(self::UNIT_TEST_USER, '47d15e3ec8');
  334. $this->assertNotNull($co);
  335. }
  336. public function providesCalendarQueryParameters() {
  337. return [
  338. 'all' => [[0, 1, 2, 3], [], []],
  339. 'only-todos' => [[], ['name' => 'VTODO'], []],
  340. 'only-events' => [[0, 1, 2, 3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => null, 'end' => null], 'prop-filters' => []]],],
  341. 'start' => [[1, 2, 3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => new DateTime('2013-09-12 14:00:00', new DateTimeZone('UTC')), 'end' => null], 'prop-filters' => []]],],
  342. 'end' => [[0], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => null, 'end' => new DateTime('2013-09-12 14:00:00', new DateTimeZone('UTC'))], 'prop-filters' => []]],],
  343. 'future' => [[3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => new DateTime('2099-09-12 14:00:00', new DateTimeZone('UTC')), 'end' => null], 'prop-filters' => []]],],
  344. ];
  345. }
  346. public function testSyncSupport() {
  347. $calendarId = $this->createTestCalendar();
  348. // fist call without synctoken
  349. $changes = $this->backend->getChangesForCalendar($calendarId, '', 1);
  350. $syncToken = $changes['syncToken'];
  351. // add a change
  352. $event = $this->createEvent($calendarId, '20130912T130000Z', '20130912T140000Z');
  353. // look for changes
  354. $changes = $this->backend->getChangesForCalendar($calendarId, $syncToken, 1);
  355. $this->assertEquals($event, $changes['added'][0]);
  356. }
  357. public function testPublications() {
  358. $this->dispatcher->expects($this->at(0))
  359. ->method('dispatch')
  360. ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendar');
  361. $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
  362. $calendarInfo = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER)[0];
  363. /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject $l10n */
  364. $l10n = $this->createMock(IL10N::class);
  365. $calendar = new Calendar($this->backend, $calendarInfo, $l10n);
  366. $calendar->setPublishStatus(true);
  367. $this->assertNotEquals(false, $calendar->getPublishStatus());
  368. $publicCalendars = $this->backend->getPublicCalendars();
  369. $this->assertCount(1, $publicCalendars);
  370. $this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
  371. $publicCalendarURI = $publicCalendars[0]['uri'];
  372. $publicCalendar = $this->backend->getPublicCalendar($publicCalendarURI);
  373. $this->assertEquals(true, $publicCalendar['{http://owncloud.org/ns}public']);
  374. $calendar->setPublishStatus(false);
  375. $this->assertEquals(false, $calendar->getPublishStatus());
  376. $this->setExpectedException('Sabre\DAV\Exception\NotFound');
  377. $this->backend->getPublicCalendar($publicCalendarURI);
  378. }
  379. public function testSubscriptions() {
  380. $id = $this->backend->createSubscription(self::UNIT_TEST_USER, 'Subscription', [
  381. '{http://calendarserver.org/ns/}source' => new Href('test-source'),
  382. '{http://apple.com/ns/ical/}calendar-color' => '#1C4587',
  383. '{http://calendarserver.org/ns/}subscribed-strip-todos' => ''
  384. ]);
  385. $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER);
  386. $this->assertCount(1, $subscriptions);
  387. $this->assertEquals('#1C4587', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']);
  388. $this->assertEquals(true, $subscriptions[0]['{http://calendarserver.org/ns/}subscribed-strip-todos']);
  389. $this->assertEquals($id, $subscriptions[0]['id']);
  390. $patch = new PropPatch([
  391. '{DAV:}displayname' => 'Unit test',
  392. '{http://apple.com/ns/ical/}calendar-color' => '#ac0606',
  393. ]);
  394. $this->backend->updateSubscription($id, $patch);
  395. $patch->commit();
  396. $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER);
  397. $this->assertCount(1, $subscriptions);
  398. $this->assertEquals($id, $subscriptions[0]['id']);
  399. $this->assertEquals('Unit test', $subscriptions[0]['{DAV:}displayname']);
  400. $this->assertEquals('#ac0606', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']);
  401. $this->backend->deleteSubscription($id);
  402. $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER);
  403. $this->assertCount(0, $subscriptions);
  404. }
  405. public function testScheduling() {
  406. $this->backend->createSchedulingObject(self::UNIT_TEST_USER, 'Sample Schedule', '');
  407. $sos = $this->backend->getSchedulingObjects(self::UNIT_TEST_USER);
  408. $this->assertCount(1, $sos);
  409. $so = $this->backend->getSchedulingObject(self::UNIT_TEST_USER, 'Sample Schedule');
  410. $this->assertNotNull($so);
  411. $this->backend->deleteSchedulingObject(self::UNIT_TEST_USER, 'Sample Schedule');
  412. $sos = $this->backend->getSchedulingObjects(self::UNIT_TEST_USER);
  413. $this->assertCount(0, $sos);
  414. }
  415. /**
  416. * @dataProvider providesCalDataForGetDenormalizedData
  417. */
  418. public function testGetDenormalizedData($expected, $key, $calData) {
  419. $actual = $this->backend->getDenormalizedData($calData);
  420. $this->assertEquals($expected, $actual[$key]);
  421. }
  422. public function providesCalDataForGetDenormalizedData() {
  423. return [
  424. 'first occurrence before unix epoch starts' => [0, 'firstOccurence', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nDTSTART;VALUE=DATE:16040222\r\nDTEND;VALUE=DATE:16040223\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
  425. 'no first occurrence because yearly' => [null, 'firstOccurence', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
  426. 'CLASS:PRIVATE' => [CalDavBackend::CLASSIFICATION_PRIVATE, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:PRIVATE\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
  427. 'CLASS:PUBLIC' => [CalDavBackend::CLASSIFICATION_PUBLIC, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:PUBLIC\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
  428. 'CLASS:CONFIDENTIAL' => [CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:CONFIDENTIAL\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
  429. 'no class set -> public' => [CalDavBackend::CLASSIFICATION_PUBLIC, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nTRANSP:OPAQUE\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
  430. 'unknown class -> private' => [CalDavBackend::CLASSIFICATION_PRIVATE, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:VERTRAULICH\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
  431. ];
  432. }
  433. }