21 protected $setupCalDAV =
false;
22 protected $setupCardDAV =
false;
23 protected $setupACL =
false;
24 protected $setupCalDAVSharing =
false;
25 protected $setupCalDAVScheduling =
false;
26 protected $setupCalDAVSubscriptions =
false;
27 protected $setupCalDAVICSExport =
false;
28 protected $setupLocks =
false;
29 protected $setupFiles =
false;
30 protected $setupSharing =
false;
31 protected $setupPropertyStorage =
false;
38 protected $caldavCalendars = [];
39 protected $caldavCalendarObjects = [];
41 protected $carddavAddressBooks = [];
42 protected $carddavCards = [];
109 protected $autoLogin = null;
113 $this->initializeEverything();
119 $this->setUpBackends();
123 $this->server->sapi =
new HTTP\SapiMock();
124 $this->server->debugExceptions =
true;
126 if ($this->setupCalDAV) {
128 $this->server->addPlugin($this->caldavPlugin);
130 if ($this->setupCalDAVSharing || $this->setupSharing) {
132 $this->server->addPlugin($this->sharingPlugin);
134 if ($this->setupCalDAVSharing) {
136 $this->server->addPlugin($this->caldavSharingPlugin);
138 if ($this->setupCalDAVScheduling) {
140 $this->server->addPlugin($this->caldavSchedulePlugin);
142 if ($this->setupCalDAVSubscriptions) {
143 $this->server->addPlugin(
new CalDAV\Subscriptions\Plugin());
145 if ($this->setupCalDAVICSExport) {
147 $this->server->addPlugin($this->caldavICSExportPlugin);
149 if ($this->setupCardDAV) {
151 $this->server->addPlugin($this->carddavPlugin);
153 if ($this->setupLocks) {
157 $this->server->addPlugin($this->locksPlugin);
159 if ($this->setupPropertyStorage) {
161 $this->propertyStorageBackend
163 $this->server->addPlugin($this->propertyStoragePlugin);
165 if ($this->autoLogin) {
166 $this->autoLogin($this->autoLogin);
168 if ($this->setupACL) {
170 if (!$this->autoLogin) {
171 $this->aclPlugin->allowUnauthenticatedAccess =
false;
173 $this->aclPlugin->adminPrincipals = [
'principals/admin'];
174 $this->server->addPlugin($this->aclPlugin);
200 $this->server->httpRequest =
$request;
202 $this->server->exec();
204 if ($expectedStatus) {
205 $responseBody = $expectedStatus !==
$response->getStatus() ?
$response->getBodyAsString() :
'';
206 $this->assertEquals($expectedStatus,
$response->getStatus(),
'Incorrect HTTP status received for request. Response body: ' . $responseBody);
208 return $this->server->httpResponse;
224 if ($oldAuth = $this->server->getPlugin(
'auth')) {
225 $this->server->removeListener(
'beforeMethod', [$oldAuth,
'beforeMethod']);
227 $this->server->addPlugin($this->authPlugin);
238 if ($this->setupCalDAV) {
240 $this->principalBackend,
244 if ($this->setupCardDAV) {
246 $this->principalBackend,
247 $this->carddavBackend
251 if ($this->setupCalDAV) {
253 $this->principalBackend
255 } elseif ($this->setupCardDAV || $this->setupACL) {
257 $this->principalBackend
260 if ($this->setupFiles) {
270 if ($this->setupCalDAVSharing && is_null($this->caldavBackend)) {
273 if ($this->setupCalDAVSubscriptions && is_null($this->caldavBackend)) {
276 if ($this->setupCalDAV && is_null($this->caldavBackend)) {
277 if ($this->setupCalDAVScheduling) {
280 $this->caldavBackend =
new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects);
283 if ($this->setupCardDAV && is_null($this->carddavBackend)) {
284 $this->carddavBackend =
new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards);
286 if ($this->setupCardDAV || $this->setupCalDAV || $this->setupACL) {
289 if ($this->setupLocks) {
292 if ($this->setupPropertyStorage) {
301 $resp = $this->request($req);
302 $this->assertEquals((
int)$expectedStatus, (
int)$resp->status,
'Incorrect HTTP status received: ' . $resp->body);
This plugin provides Authentication for a WebDAV server.
foreach($paths as $path) $request
The Request class represents a single HTTP request.
setUpTree()
Override this to provide your own Tree for your test-case.
This plugin implements support for caldav sharing.
This plugin implements HTTP requests and properties related to:
This class represents a single HTTP response.
This class may be used as a basis for other webdav-related unittests.
autoLogin($userName)
This function takes a username and sets the server in a state where this user is logged in...
assertHttpStatus($expectedStatus, HTTP\Request $req)
This is a mock CalDAV backend that supports subscriptions.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.