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