]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php
Merge branch '3.6-release'
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / ExpandEventsDoubleEventsTest.php
1 <?php
2
3 use Sabre\VObject;
4
5 /**
6  * This unittests is created to find out why certain events show up twice.
7  *
8  * Hopefully, by the time I'm done with this, I've both found the problem, and
9  * fixed it :)
10  *
11  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12  * @author Evert Pot (http://www.rooftopsolutions.nl/)
13  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14  */
15 class Sabre_CalDAV_ExpandEventsDoubleEventsTest extends Sabre_DAVServerTest {
16
17     protected $setupCalDAV = true;
18
19     protected $caldavCalendars = array(
20         array(
21             'id' => 1,
22             'name' => 'Calendar',
23             'principaluri' => 'principals/user1',
24             'uri' => 'calendar1',
25         )
26     );
27
28     protected $caldavCalendarObjects = array(
29         1 => array(
30            'event.ics' => array(
31                 'calendardata' => 'BEGIN:VCALENDAR
32 VERSION:2.0
33 BEGIN:VEVENT
34 UID:foobar
35 DTEND;TZID=Europe/Berlin:20120207T191500
36 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
37 SUMMARY:RecurringEvents 3 times
38 DTSTART;TZID=Europe/Berlin:20120207T181500
39 END:VEVENT
40 BEGIN:VEVENT
41 CREATED:20120207T111900Z
42 UID:foobar
43 DTEND;TZID=Europe/Berlin:20120208T191500
44 SUMMARY:RecurringEvents 3 times OVERWRITTEN
45 DTSTART;TZID=Europe/Berlin:20120208T181500
46 RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500
47 END:VEVENT
48 END:VCALENDAR
49 ',
50             ),
51         ),
52     );
53
54     function testExpand() {
55
56         $request = new Sabre_HTTP_Request(array(
57             'REQUEST_METHOD' => 'REPORT',
58             'HTTP_CONTENT_TYPE' => 'application/xml',
59             'REQUEST_URI' => '/calendars/user1/calendar1',
60             'HTTP_DEPTH' => '1',
61         ));
62
63         $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
64 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
65     <D:prop>
66         <C:calendar-data>
67             <C:expand start="20120205T230000Z" end="20120212T225959Z"/>
68         </C:calendar-data>
69         <D:getetag/>
70     </D:prop>
71     <C:filter>
72         <C:comp-filter name="VCALENDAR">
73             <C:comp-filter name="VEVENT">
74                 <C:time-range start="20120205T230000Z" end="20120212T225959Z"/>
75             </C:comp-filter>
76         </C:comp-filter>
77     </C:filter>
78 </C:calendar-query>');
79
80         $response = $this->request($request);
81
82         // Everts super awesome xml parser.
83         $body = substr(
84             $response->body,
85             $start = strpos($response->body, 'BEGIN:VCALENDAR'),
86             strpos($response->body, 'END:VCALENDAR') - $start + 13
87         );
88         $body = str_replace('&#13;','',$body);
89
90         $vObject = VObject\Reader::read($body);
91
92         // We only expect 3 events
93         $this->assertEquals(3, count($vObject->VEVENT),'We got 6 events instead of 3. Output: ' . $body);
94
95         // TZID should be gone
96         $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID']));
97
98     }
99
100 }
101