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_ExpandEventsDTSTARTandDTENDbyDayTest 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=WEEKLY;INTERVAL=1;BYDAY=TU,TH
33 SUMMARY:RecurringEvents on tuesday and thursday
34 DTSTART;TZID=Europe/Berlin:20120207T181500
42 function testExpandRecurringByDayEvent() {
44 $request = new Sabre_HTTP_Request(array(
45 'REQUEST_METHOD' => 'REPORT',
46 'HTTP_CONTENT_TYPE' => 'application/xml',
47 'REQUEST_URI' => '/calendars/user1/calendar1',
51 $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
52 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
55 <C:expand start="20120210T230000Z" end="20120217T225959Z"/>
60 <C:comp-filter name="VCALENDAR">
61 <C:comp-filter name="VEVENT">
62 <C:time-range start="20120210T230000Z" end="20120217T225959Z"/>
66 </C:calendar-query>');
68 $response = $this->request($request);
70 // Everts super awesome xml parser.
73 $start = strpos($response->body, 'BEGIN:VCALENDAR'),
74 strpos($response->body, 'END:VCALENDAR') - $start + 13
76 $body = str_replace(' ','',$body);
78 $vObject = Sabre_VObject_Reader::read($body);
80 $this->assertEquals(2, count($vObject->VEVENT));
82 // check if DTSTARTs and DTENDs are correct
83 foreach ($vObject->VEVENT as $vevent) {
84 /** @var $vevent Sabre_VObject_Component_VEvent */
85 foreach ($vevent->children as $child) {
86 /** @var $child Sabre_VObject_Property */
88 if ($child->name == 'DTSTART') {
89 // DTSTART has to be one of two valid values
90 $this->assertContains($child->value, array('20120214T171500Z', '20120216T171500Z'), 'DTSTART is not a valid value: '.$child->value);
91 } elseif ($child->name == 'DTEND') {
92 // DTEND has to be one of two valid values
93 $this->assertContains($child->value, array('20120214T181500Z', '20120216T181500Z'), 'DTEND is not a valid value: '.$child->value);