6 * This unittests is created to find out why recurring events have wrong DTSTART value
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_ExpandEventsDTSTARTandDTENDbyDayTest extends Sabre_DAVServerTest {
15 protected $setupCalDAV = true;
17 protected $caldavCalendars = array(
21 'principaluri' => 'principals/user1',
26 protected $caldavCalendarObjects = array(
29 'calendardata' => 'BEGIN:VCALENDAR
33 DTEND;TZID=Europe/Berlin:20120207T191500
34 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
35 SUMMARY:RecurringEvents on tuesday and thursday
36 DTSTART;TZID=Europe/Berlin:20120207T181500
44 function testExpandRecurringByDayEvent() {
46 $request = new Sabre_HTTP_Request(array(
47 'REQUEST_METHOD' => 'REPORT',
48 'HTTP_CONTENT_TYPE' => 'application/xml',
49 'REQUEST_URI' => '/calendars/user1/calendar1',
53 $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
54 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
57 <C:expand start="20120210T230000Z" end="20120217T225959Z"/>
62 <C:comp-filter name="VCALENDAR">
63 <C:comp-filter name="VEVENT">
64 <C:time-range start="20120210T230000Z" end="20120217T225959Z"/>
68 </C:calendar-query>');
70 $response = $this->request($request);
72 // Everts super awesome xml parser.
75 $start = strpos($response->body, 'BEGIN:VCALENDAR'),
76 strpos($response->body, 'END:VCALENDAR') - $start + 13
78 $body = str_replace(' ','',$body);
80 $vObject = VObject\Reader::read($body);
82 $this->assertEquals(2, count($vObject->VEVENT));
84 // check if DTSTARTs and DTENDs are correct
85 foreach ($vObject->VEVENT as $vevent) {
86 /** @var $vevent Sabre\VObject\Component\VEvent */
87 foreach ($vevent->children as $child) {
88 /** @var $child Sabre\VObject\Property */
90 if ($child->name == 'DTSTART') {
91 // DTSTART has to be one of two valid values
92 $this->assertContains($child->value, array('20120214T171500Z', '20120216T171500Z'), 'DTSTART is not a valid value: '.$child->value);
93 } elseif ($child->name == 'DTEND') {
94 // DTEND has to be one of two valid values
95 $this->assertContains($child->value, array('20120214T181500Z', '20120216T181500Z'), 'DTEND is not a valid value: '.$child->value);