6 * This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID
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
13 class Sabre_CalDAV_Issue203Test extends Sabre_DAVServerTest {
15 protected $setupCalDAV = true;
17 protected $caldavCalendars = array(
21 'principaluri' => 'principals/user1',
26 protected $caldavCalendarObjects = array(
29 'calendardata' => 'BEGIN:VCALENDAR
32 UID:20120330T155305CEST-6585fBUVgV
33 DTSTAMP:20120330T135305Z
34 DTSTART;TZID=Europe/Berlin:20120326T155200
35 DTEND;TZID=Europe/Berlin:20120326T165200
36 RRULE:FREQ=DAILY;COUNT=2;INTERVAL=1
37 SUMMARY:original summary
41 UID:20120330T155305CEST-6585fBUVgV
42 DTSTAMP:20120330T135352Z
44 DTSTART;TZID=Europe/Berlin:20120328T155200
45 DTEND;TZID=Europe/Berlin:20120328T165200
46 RECURRENCE-ID;TZID=Europe/Berlin:20120327T155200
48 SUMMARY:overwritten summary
57 function testIssue203() {
59 $request = new Sabre_HTTP_Request(array(
60 'REQUEST_METHOD' => 'REPORT',
61 'HTTP_CONTENT_TYPE' => 'application/xml',
62 'REQUEST_URI' => '/calendars/user1/calendar1',
66 $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
67 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
70 <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
75 <C:comp-filter name="VCALENDAR">
76 <C:comp-filter name="VEVENT">
77 <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
81 </C:calendar-query>');
83 $response = $this->request($request);
85 // Everts super awesome xml parser.
88 $start = strpos($response->body, 'BEGIN:VCALENDAR'),
89 strpos($response->body, 'END:VCALENDAR') - $start + 13
91 $body = str_replace(' ','',$body);
93 $vObject = VObject\Reader::read($body);
95 $this->assertEquals(2, count($vObject->VEVENT));
98 $expectedEvents = array(
100 'DTSTART' => '20120326T135200Z',
101 'DTEND' => '20120326T145200Z',
102 'SUMMARY' => 'original summary',
105 'DTSTART' => '20120328T135200Z',
106 'DTEND' => '20120328T145200Z',
107 'SUMMARY' => 'overwritten summary',
108 'RECURRENCE-ID' => '20120327T135200Z',
112 // try to match agains $expectedEvents array
113 foreach ($expectedEvents as $expectedEvent) {
117 foreach ($vObject->VEVENT as $vevent) {
118 /** @var $vevent Sabre\VObject\Component\VEvent */
120 foreach ($vevent->children as $child) {
121 /** @var $child Sabre\VObject\Property */
123 if (isset($expectedEvent[$child->name])) {
124 if ($expectedEvent[$child->name] != $child->value) {
134 $this->assertTrue($matching, 'Did not find the following event in the response: '.var_export($expectedEvent, true));