4 * This unittests is created to find out why recurring events have wrong DTSTART value
7 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
8 * @author Evert Pot (http://www.rooftopsolutions.nl/)
9 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
11 class Sabre_CalDAV_ExpandEventsDTSTARTandDTENDTest extends Sabre_DAVServerTest {
13 protected $setupCalDAV = true;
15 protected $caldavCalendars = array(
19 'principaluri' => 'principals/user1',
24 protected $caldavCalendarObjects = array(
27 'calendardata' => 'BEGIN:VCALENDAR
31 DTEND;TZID=Europe/Berlin:20120207T191500
32 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
33 SUMMARY:RecurringEvents 3 times
34 DTSTART;TZID=Europe/Berlin:20120207T181500
37 CREATED:20120207T111900Z
39 DTEND;TZID=Europe/Berlin:20120208T191500
40 SUMMARY:RecurringEvents 3 times OVERWRITTEN
41 DTSTART;TZID=Europe/Berlin:20120208T181500
42 RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500
50 function testExpand() {
52 $request = new Sabre_HTTP_Request(array(
53 'REQUEST_METHOD' => 'REPORT',
54 'HTTP_CONTENT_TYPE' => 'application/xml',
55 'REQUEST_URI' => '/calendars/user1/calendar1',
59 $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
60 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
63 <C:expand start="20120205T230000Z" end="20120212T225959Z"/>
68 <C:comp-filter name="VCALENDAR">
69 <C:comp-filter name="VEVENT">
70 <C:time-range start="20120205T230000Z" end="20120212T225959Z"/>
74 </C:calendar-query>');
76 $response = $this->request($request);
78 // Everts super awesome xml parser.
81 $start = strpos($response->body, 'BEGIN:VCALENDAR'),
82 strpos($response->body, 'END:VCALENDAR') - $start + 13
84 $body = str_replace(' ','',$body);
86 $vObject = Sabre_VObject_Reader::read($body);
88 // check if DTSTARTs and DTENDs are correct
89 foreach ($vObject->VEVENT as $vevent) {
90 /** @var $vevent Sabre_VObject_Component_VEvent */
91 foreach ($vevent->children as $child) {
92 /** @var $child Sabre_VObject_Property */
94 if ($child->name == 'DTSTART') {
95 // DTSTART has to be one of three valid values
96 $this->assertContains($child->value, array('20120207T171500Z', '20120208T171500Z', '20120209T171500Z'), 'DTSTART is not a valid value: '.$child->value);
97 } elseif ($child->name == 'DTEND') {
98 // DTEND has to be one of three valid values
99 $this->assertContains($child->value, array('20120207T181500Z', '20120208T181500Z', '20120209T181500Z'), 'DTEND is not a valid value: '.$child->value);