1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\HTTP; 6*a1a3b679SAndreas Boehleruse Sabre\VObject; 7*a1a3b679SAndreas Boehler 8*a1a3b679SAndreas Boehler/** 9*a1a3b679SAndreas Boehler * This unittests is created to find out why certain events show up twice. 10*a1a3b679SAndreas Boehler * 11*a1a3b679SAndreas Boehler * Hopefully, by the time I'm done with this, I've both found the problem, and 12*a1a3b679SAndreas Boehler * fixed it :) 13*a1a3b679SAndreas Boehler * 14*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 15*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/) 16*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License 17*a1a3b679SAndreas Boehler */ 18*a1a3b679SAndreas Boehlerclass ExpandEventsDoubleEventsTest extends \Sabre\DAVServerTest { 19*a1a3b679SAndreas Boehler 20*a1a3b679SAndreas Boehler protected $setupCalDAV = true; 21*a1a3b679SAndreas Boehler 22*a1a3b679SAndreas Boehler protected $caldavCalendars = array( 23*a1a3b679SAndreas Boehler array( 24*a1a3b679SAndreas Boehler 'id' => 1, 25*a1a3b679SAndreas Boehler 'name' => 'Calendar', 26*a1a3b679SAndreas Boehler 'principaluri' => 'principals/user1', 27*a1a3b679SAndreas Boehler 'uri' => 'calendar1', 28*a1a3b679SAndreas Boehler ) 29*a1a3b679SAndreas Boehler ); 30*a1a3b679SAndreas Boehler 31*a1a3b679SAndreas Boehler protected $caldavCalendarObjects = array( 32*a1a3b679SAndreas Boehler 1 => array( 33*a1a3b679SAndreas Boehler 'event.ics' => array( 34*a1a3b679SAndreas Boehler 'calendardata' => 'BEGIN:VCALENDAR 35*a1a3b679SAndreas BoehlerVERSION:2.0 36*a1a3b679SAndreas BoehlerBEGIN:VEVENT 37*a1a3b679SAndreas BoehlerUID:foobar 38*a1a3b679SAndreas BoehlerDTEND;TZID=Europe/Berlin:20120207T191500 39*a1a3b679SAndreas BoehlerRRULE:FREQ=DAILY;INTERVAL=1;COUNT=3 40*a1a3b679SAndreas BoehlerSUMMARY:RecurringEvents 3 times 41*a1a3b679SAndreas BoehlerDTSTART;TZID=Europe/Berlin:20120207T181500 42*a1a3b679SAndreas BoehlerEND:VEVENT 43*a1a3b679SAndreas BoehlerBEGIN:VEVENT 44*a1a3b679SAndreas BoehlerCREATED:20120207T111900Z 45*a1a3b679SAndreas BoehlerUID:foobar 46*a1a3b679SAndreas BoehlerDTEND;TZID=Europe/Berlin:20120208T191500 47*a1a3b679SAndreas BoehlerSUMMARY:RecurringEvents 3 times OVERWRITTEN 48*a1a3b679SAndreas BoehlerDTSTART;TZID=Europe/Berlin:20120208T181500 49*a1a3b679SAndreas BoehlerRECURRENCE-ID;TZID=Europe/Berlin:20120208T181500 50*a1a3b679SAndreas BoehlerEND:VEVENT 51*a1a3b679SAndreas BoehlerEND:VCALENDAR 52*a1a3b679SAndreas Boehler', 53*a1a3b679SAndreas Boehler ), 54*a1a3b679SAndreas Boehler ), 55*a1a3b679SAndreas Boehler ); 56*a1a3b679SAndreas Boehler 57*a1a3b679SAndreas Boehler function testExpand() { 58*a1a3b679SAndreas Boehler 59*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray([ 60*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 61*a1a3b679SAndreas Boehler 'HTTP_CONTENT_TYPE' => 'application/xml', 62*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/calendars/user1/calendar1', 63*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '1', 64*a1a3b679SAndreas Boehler ]); 65*a1a3b679SAndreas Boehler 66*a1a3b679SAndreas Boehler $request->setBody('<?xml version="1.0" encoding="utf-8" ?> 67*a1a3b679SAndreas Boehler<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> 68*a1a3b679SAndreas Boehler <D:prop> 69*a1a3b679SAndreas Boehler <C:calendar-data> 70*a1a3b679SAndreas Boehler <C:expand start="20120205T230000Z" end="20120212T225959Z"/> 71*a1a3b679SAndreas Boehler </C:calendar-data> 72*a1a3b679SAndreas Boehler <D:getetag/> 73*a1a3b679SAndreas Boehler </D:prop> 74*a1a3b679SAndreas Boehler <C:filter> 75*a1a3b679SAndreas Boehler <C:comp-filter name="VCALENDAR"> 76*a1a3b679SAndreas Boehler <C:comp-filter name="VEVENT"> 77*a1a3b679SAndreas Boehler <C:time-range start="20120205T230000Z" end="20120212T225959Z"/> 78*a1a3b679SAndreas Boehler </C:comp-filter> 79*a1a3b679SAndreas Boehler </C:comp-filter> 80*a1a3b679SAndreas Boehler </C:filter> 81*a1a3b679SAndreas Boehler</C:calendar-query>'); 82*a1a3b679SAndreas Boehler 83*a1a3b679SAndreas Boehler $response = $this->request($request); 84*a1a3b679SAndreas Boehler 85*a1a3b679SAndreas Boehler // Everts super awesome xml parser. 86*a1a3b679SAndreas Boehler $body = substr( 87*a1a3b679SAndreas Boehler $response->body, 88*a1a3b679SAndreas Boehler $start = strpos($response->body, 'BEGIN:VCALENDAR'), 89*a1a3b679SAndreas Boehler strpos($response->body, 'END:VCALENDAR') - $start + 13 90*a1a3b679SAndreas Boehler ); 91*a1a3b679SAndreas Boehler $body = str_replace(' ','',$body); 92*a1a3b679SAndreas Boehler 93*a1a3b679SAndreas Boehler $vObject = VObject\Reader::read($body); 94*a1a3b679SAndreas Boehler 95*a1a3b679SAndreas Boehler // We only expect 3 events 96*a1a3b679SAndreas Boehler $this->assertEquals(3, count($vObject->VEVENT),'We got 6 events instead of 3. Output: ' . $body); 97*a1a3b679SAndreas Boehler 98*a1a3b679SAndreas Boehler // TZID should be gone 99*a1a3b679SAndreas Boehler $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID'])); 100*a1a3b679SAndreas Boehler 101*a1a3b679SAndreas Boehler } 102*a1a3b679SAndreas Boehler 103*a1a3b679SAndreas Boehler} 104*a1a3b679SAndreas Boehler 105