6 * This unittest is created to check if queries for time-range include the start timestamp or not
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_GetEventsByTimerangeTest extends Sabre_DAVServerTest {
15 protected $setupCalDAV = true;
17 protected $caldavCalendars = array(
21 'principaluri' => 'principals/user1',
26 protected $caldavCalendarObjects = array(
29 'calendardata' => 'BEGIN:VCALENDAR
32 CREATED:20120313T142342Z
33 UID:171EBEFC-C951-499D-B234-7BA7D677B45D
34 DTEND;TZID=Europe/Berlin:20120227T000000
37 DTSTART;TZID=Europe/Berlin:20120227T000000
38 DTSTAMP:20120313T142416Z
47 function testQueryTimerange() {
49 $request = new Sabre_HTTP_Request(array(
50 'REQUEST_METHOD' => 'REPORT',
51 'HTTP_CONTENT_TYPE' => 'application/xml',
52 'REQUEST_URI' => '/calendars/user1/calendar1',
56 $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
57 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
60 <C:expand start="20120226T230000Z" end="20120228T225959Z"/>
65 <C:comp-filter name="VCALENDAR">
66 <C:comp-filter name="VEVENT">
67 <C:time-range start="20120226T230000Z" end="20120228T225959Z"/>
71 </C:calendar-query>');
73 $response = $this->request($request);
75 if (strpos($response->body, 'BEGIN:VCALENDAR') === false) {
76 $this->fail('Got no events instead of 1. Output: '.$response->body);
79 // Everts super awesome xml parser.
82 $start = strpos($response->body, 'BEGIN:VCALENDAR'),
83 strpos($response->body, 'END:VCALENDAR') - $start + 13
85 $body = str_replace(' ','',$body);
87 $vObject = VObject\Reader::read($body);
90 $this->assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body);