From b35122f7a6ad42756c35bb60ba1f06c3dcd45c77 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 21 Oct 2013 15:46:31 -0700 Subject: add sabre (1.8.x) via composer in the !@#$ place it wants to be --- vendor/sabre/dav/tests/Sabre/DAVServerTest.php | 179 +++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 vendor/sabre/dav/tests/Sabre/DAVServerTest.php (limited to 'vendor/sabre/dav/tests/Sabre/DAVServerTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php new file mode 100644 index 000000000..5dc72fda0 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php @@ -0,0 +1,179 @@ +setUpBackends(); + $this->setUpTree(); + + $this->server = new DAV\Server($this->tree); + $this->server->debugExceptions = true; + + if ($this->setupCalDAV) { + $this->caldavPlugin = new CalDAV\Plugin(); + $this->server->addPlugin($this->caldavPlugin); + } + if ($this->setupCalDAVSharing) { + $this->caldavSharingPlugin = new CalDAV\SharingPlugin(); + $this->server->addPlugin($this->caldavSharingPlugin); + } + if ($this->setupCardDAV) { + $this->carddavPlugin = new CardDAV\Plugin(); + $this->server->addPlugin($this->carddavPlugin); + } + if ($this->setupACL) { + $this->aclPlugin = new DAVACL\Plugin(); + $this->server->addPlugin($this->aclPlugin); + } + if ($this->autoLogin) { + $authBackend = new DAV\Auth\Backend\Mock(); + $authBackend->defaultUser = $this->autoLogin; + $this->authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV'); + $this->server->addPlugin($this->authPlugin); + + // This will trigger the actual login procedure + $this->authPlugin->beforeMethod('OPTIONS','/'); + } + + } + + /** + * Makes a request, and returns a response object. + * + * You can either pass an instance 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 HTTP\Request($request); + } + $this->server->httpRequest = $request; + $this->server->httpResponse = new HTTP\ResponseMock(); + $this->server->exec(); + + return $this->server->httpResponse; + + } + + function setUpTree() { + + if ($this->setupCalDAV) { + $this->tree[] = new CalDAV\CalendarRootNode( + $this->principalBackend, + $this->caldavBackend + ); + } + if ($this->setupCardDAV) { + $this->tree[] = new CardDAV\AddressBookRoot( + $this->principalBackend, + $this->carddavBackend + ); + } + + if ($this->setupCardDAV || $this->setupCalDAV) { + $this->tree[] = new DAVACL\PrincipalCollection( + $this->principalBackend + ); + } + + } + + function setUpBackends() { + + if ($this->setupCalDAV && is_null($this->caldavBackend)) { + $this->caldavBackend = new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects); + } + if ($this->setupCardDAV && is_null($this->carddavBackend)) { + $this->carddavBackend = new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards); + } + if ($this->setupCardDAV || $this->setupCalDAV) { + $this->principalBackend = new DAVACL\PrincipalBackend\Mock(); + } + + } + + + function assertHTTPStatus($expectedStatus, HTTP\Request $req) { + + $resp = $this->request($req); + $this->assertEquals($resp->getStatusMessage($expectedStatus), $resp->status,'Incorrect HTTP status received: ' . $resp->body); + + } + +} -- cgit v1.2.3