[ 'obj1' => [ 'calendarid' => 1, 'uri' => 'event1.ics', 'calendardata' => $obj1, ], 'obj2' => [ 'calendarid' => 1, 'uri' => 'event2.ics', 'calendardata' => $obj2 ], 'obj3' => [ 'calendarid' => 1, 'uri' => 'event3.ics', 'calendardata' => $obj3 ] ], ]; $caldavBackend = new Backend\Mock([], $calendarData); $calendar = new Calendar($caldavBackend, [ 'id' => 1, 'uri' => 'calendar', 'principaluri' => 'principals/user1', '{' . Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", ]); $this->server = new DAV\Server([$calendar]); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_URI' => '/calendar', ]); $this->server->httpRequest = $request; $this->server->httpResponse = new HTTP\ResponseMock(); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); } function testFreeBusyReport() { $reportXML = << XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report); $this->assertEquals(200, $this->server->httpResponse->status); $this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type')); $this->assertTrue(strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY')!==false); $this->assertTrue(strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z')!==false); $this->assertTrue(strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z')!==false); } /** * @expectedException Sabre\DAV\Exception\BadRequest */ function testFreeBusyReportNoTimeRange() { $reportXML = << XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report); } /** * @expectedException Sabre\DAV\Exception\NotImplemented */ function testFreeBusyReportWrongNode() { $request = HTTP\Sapi::createFromServerArray(array( 'REQUEST_URI' => '/', )); $this->server->httpRequest = $request; $reportXML = << XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report); } /** * @expectedException Sabre\DAV\Exception */ function testFreeBusyReportNoACLPlugin() { $this->server = new DAV\Server(); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); $reportXML = << XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report); } }