1<?php
2
3namespace Sabre\CalDAV;
4use Sabre\HTTP;
5
6/**
7 * This unittest is created to check if the time-range filter is working correctly with all-day-events
8 *
9 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
10 * @author Evert Pot (http://evertpot.com/)
11 * @license http://sabre.io/license/ Modified BSD License
12 */
13class Issue228Test extends \Sabre\DAVServerTest {
14
15    protected $setupCalDAV = true;
16
17    protected $caldavCalendars = array(
18        array(
19            'id' => 1,
20            'name' => 'Calendar',
21            'principaluri' => 'principals/user1',
22            'uri' => 'calendar1',
23        )
24    );
25
26    protected $caldavCalendarObjects = array(
27        1 => array(
28            'event.ics' => array(
29                'calendardata' => 'BEGIN:VCALENDAR
30VERSION:2.0
31BEGIN:VEVENT
32UID:20120730T113415CEST-6804EGphkd@xxxxxx.de
33DTSTAMP:20120730T093415Z
34DTSTART;VALUE=DATE:20120729
35DTEND;VALUE=DATE:20120730
36SUMMARY:sunday event
37TRANSP:TRANSPARENT
38END:VEVENT
39END:VCALENDAR
40',
41            ),
42        ),
43    );
44
45    function testIssue228() {
46
47        $request = HTTP\Sapi::createFromServerArray(array(
48            'REQUEST_METHOD' => 'REPORT',
49            'HTTP_CONTENT_TYPE' => 'application/xml',
50            'REQUEST_URI' => '/calendars/user1/calendar1',
51            'HTTP_DEPTH' => '1',
52        ));
53
54        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
55<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
56  <D:prop>
57    <C:calendar-data>
58  <C:expand start="20120730T095609Z"
59            end="20120813T095609Z"/>
60</C:calendar-data>
61    <D:getetag/>
62  </D:prop>
63  <C:filter>
64    <C:comp-filter name="VCALENDAR">
65      <C:comp-filter name="VEVENT">
66        <C:time-range start="20120730T095609Z" end="20120813T095609Z"/>
67      </C:comp-filter>
68    </C:comp-filter>
69  </C:filter>
70</C:calendar-query>');
71
72        $response = $this->request($request);
73
74        // We must check if absolutely nothing was returned from this query.
75        $this->assertFalse(strpos($response->body, 'BEGIN:VCALENDAR'));
76
77    }
78}
79