1<?php
2
3namespace Sabre\CalDAV;
4
5use Sabre\HTTP;
6
7/**
8 * This unittest is created to check if queries for time-range include the start timestamp or not
9 *
10 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
11 * @author Evert Pot (http://evertpot.com/)
12 * @license http://sabre.io/license/ Modified BSD License
13 */
14class GetEventsByTimerangeTest extends \Sabre\DAVServerTest {
15
16    protected $setupCalDAV = true;
17
18    protected $caldavCalendars = [
19        [
20            'id'           => 1,
21            'name'         => 'Calendar',
22            'principaluri' => 'principals/user1',
23            'uri'          => 'calendar1',
24        ]
25    ];
26
27    protected $caldavCalendarObjects = [
28        1 => [
29           'event.ics' => [
30                'calendardata' => 'BEGIN:VCALENDAR
31VERSION:2.0
32BEGIN:VEVENT
33CREATED:20120313T142342Z
34UID:171EBEFC-C951-499D-B234-7BA7D677B45D
35DTEND;TZID=Europe/Berlin:20120227T010000
36TRANSP:OPAQUE
37SUMMARY:Monday 0h
38DTSTART;TZID=Europe/Berlin:20120227T000000
39DTSTAMP:20120313T142416Z
40SEQUENCE:4
41END:VEVENT
42END:VCALENDAR
43',
44            ],
45        ],
46    ];
47
48    function testQueryTimerange() {
49
50        $request = new HTTP\Request(
51            'REPORT',
52            '/calendars/user1/calendar1',
53            [
54                'Content-Type' => 'application/xml',
55                'Depth'        => '1',
56            ]
57        );
58
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">
61    <D:prop>
62        <C:calendar-data>
63            <C:expand start="20120226T220000Z" end="20120228T225959Z"/>
64        </C:calendar-data>
65        <D:getetag/>
66    </D:prop>
67    <C:filter>
68        <C:comp-filter name="VCALENDAR">
69            <C:comp-filter name="VEVENT">
70                <C:time-range start="20120226T220000Z" end="20120228T225959Z"/>
71            </C:comp-filter>
72        </C:comp-filter>
73    </C:filter>
74</C:calendar-query>');
75
76        $response = $this->request($request);
77
78        $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR') !== false);
79
80    }
81
82}
83