1<?php
2
3namespace Sabre\CalDAV;
4use Sabre\HTTP;
5use Sabre\VObject;
6
7/**
8 * This unittest is created to check for an endless loop in Sabre\CalDAV\CalendarQueryValidator
9 *
10 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
11 * @author Evert Pot (http://evertpot.com/)
12 * @license http://sabre.io/license/ Modified BSD License
13 */
14class Issue211Test extends \Sabre\DAVServerTest {
15
16    protected $setupCalDAV = true;
17
18    protected $caldavCalendars = array(
19        array(
20            'id' => 1,
21            'name' => 'Calendar',
22            'principaluri' => 'principals/user1',
23            'uri' => 'calendar1',
24        )
25    );
26
27    protected $caldavCalendarObjects = array(
28        1 => array(
29            'event.ics' => array(
30                'calendardata' => 'BEGIN:VCALENDAR
31VERSION:2.0
32BEGIN:VEVENT
33UID:20120418T172519CEST-3510gh1hVw
34DTSTAMP:20120418T152519Z
35DTSTART;VALUE=DATE:20120330
36DTEND;VALUE=DATE:20120531
37EXDATE;TZID=Europe/Berlin:20120330T000000
38RRULE:FREQ=YEARLY;INTERVAL=1
39SEQUENCE:1
40SUMMARY:Birthday
41TRANSP:TRANSPARENT
42BEGIN:VALARM
43ACTION:EMAIL
44ATTENDEE:MAILTO:xxx@domain.de
45DESCRIPTION:Dies ist eine Kalender Erinnerung
46SUMMARY:Kalender Alarm Erinnerung
47TRIGGER;VALUE=DATE-TIME:20120329T060000Z
48END:VALARM
49END:VEVENT
50END:VCALENDAR
51',
52            ),
53        ),
54    );
55
56    function testIssue211() {
57
58        $request = HTTP\Sapi::createFromServerArray(array(
59            'REQUEST_METHOD' => 'REPORT',
60            'HTTP_CONTENT_TYPE' => 'application/xml',
61            'REQUEST_URI' => '/calendars/user1/calendar1',
62            'HTTP_DEPTH' => '1',
63        ));
64
65        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
66<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
67    <D:prop>
68        <C:calendar-data/>
69        <D:getetag/>
70    </D:prop>
71    <C:filter>
72        <C:comp-filter name="VCALENDAR">
73            <C:comp-filter name="VEVENT">
74                <C:comp-filter name="VALARM">
75                    <C:time-range start="20120426T220000Z" end="20120427T215959Z"/>
76                </C:comp-filter>
77            </C:comp-filter>
78        </C:comp-filter>
79    </C:filter>
80</C:calendar-query>');
81
82        $response = $this->request($request);
83
84        // if this assert is reached, the endless loop is gone
85        // There should be no matching events
86        $this->assertFalse(strpos('BEGIN:VEVENT', $response->body));
87
88    }
89}
90