setUpBackends(); $this->setUpTree(); $this->server = new Sabre_DAV_Server($this->tree); if ($this->setupCalDAV) { $this->caldavPlugin = new Sabre_CalDAV_Plugin(); $this->server->addPlugin($this->caldavPlugin); } if ($this->setupCardDAV) { $this->carddavPlugin = new Sabre_CardDAV_Plugin(); $this->server->addPlugin($this->carddavPlugin); } } /** * Makes a request, and returns a response object. * * You can either pass an isntance of Sabre_HTTP_Request, or an array, * which will then be used as the _SERVER array. * * @param array|Sabre_HTTP_Request $request * @return Sabre_HTTP_Response */ function request($request) { if (is_array($request)) { $request = new Sabre_HTTP_Request($request); } $this->server->httpRequest = $request; $this->server->httpResponse = new Sabre_HTTP_ResponseMock(); $this->server->exec(); return $this->server->httpResponse; } function setUpTree() { if ($this->setupCalDAV) { $this->tree[] = new Sabre_CalDAV_CalendarRootNode( $this->principalBackend, $this->caldavBackend ); } if ($this->setupCardDAV) { $this->tree[] = new Sabre_CardDAV_AddressBookRoot( $this->principalBackend, $this->carddavBackend ); } if ($this->setupCardDAV || $this->setupCalDAV) { $this->tree[] = new Sabre_DAVACL_PrincipalCollection( $this->principalBackend ); } } function setUpBackends() { if ($this->setupCalDAV) { $this->caldavBackend = new Sabre_CalDAV_Backend_Mock($this->caldavCalendars, $this->caldavCalendarObjects); } if ($this->setupCardDAV) { $this->carddavBackend = new Sabre_CardDAV_Backend_Mock($this->carddavAddressBooks, $this->carddavCards); } if ($this->setupCardDAV || $this->setupCalDAV) { $this->principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); } } function assertHTTPStatus($expectedStatus, Sabre_HTTP_Request $req) { $resp = $this->request($req); $this->assertEquals($resp->getStatusMessage($expectedStatus), $resp->status,'Incorrect HTTP status received: ' . $resp->body); } }