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