ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAVServerTest Class Reference

This class may be used as a basis for other webdav-related unittests. More...

+ Inheritance diagram for Sabre\DAVServerTest:
+ Collaboration diagram for Sabre\DAVServerTest:

Public Member Functions

 setUp ()
 
 initializeEverything ()
 
 request ($request, $expectedStatus=null)
 Makes a request, and returns a response object. More...
 
 autoLogin ($userName)
 This function takes a username and sets the server in a state where this user is logged in, and no longer requires an authentication check. More...
 
 setUpTree ()
 Override this to provide your own Tree for your test-case. More...
 
 setUpBackends ()
 
 assertHttpStatus ($expectedStatus, HTTP\Request $req)
 

Protected Attributes

 $setupCalDAV = false
 
 $setupCardDAV = false
 
 $setupACL = false
 
 $setupCalDAVSharing = false
 
 $setupCalDAVScheduling = false
 
 $setupCalDAVSubscriptions = false
 
 $setupCalDAVICSExport = false
 
 $setupLocks = false
 
 $setupFiles = false
 
 $setupSharing = false
 
 $setupPropertyStorage = false
 
 $caldavCalendars = []
 An array with calendars. More...
 
 $caldavCalendarObjects = []
 
 $carddavAddressBooks = []
 
 $carddavCards = []
 
 $server
 
 $tree = []
 
 $caldavBackend
 
 $carddavBackend
 
 $principalBackend
 
 $locksBackend
 
 $propertyStorageBackend
 
 $caldavPlugin
 
 $carddavPlugin
 
 $aclPlugin
 
 $caldavSharingPlugin
 
 $caldavSchedulePlugin
 
 $authPlugin
 
 $locksPlugin
 
 $sharingPlugin
 
 $propertyStoragePlugin
 
 $autoLogin = null
 If this string is set, we will automatically log in the user with this name. More...
 

Detailed Description

This class may be used as a basis for other webdav-related unittests.

This class is supposed to provide a reasonably big framework to quickly get a testing environment running.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 19 of file DAVServerTest.php.

Member Function Documentation

◆ assertHttpStatus()

Sabre\DAVServerTest::assertHttpStatus (   $expectedStatus,
HTTP\Request  $req 
)

Definition at line 299 of file DAVServerTest.php.

299 {
300
301 $resp = $this->request($req);
302 $this->assertEquals((int)$expectedStatus, (int)$resp->status, 'Incorrect HTTP status received: ' . $resp->body);
303
304 }
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$req
Definition: getUserInfo.php:20

References $req.

◆ autoLogin()

Sabre\DAVServerTest::autoLogin (   $userName)

This function takes a username and sets the server in a state where this user is logged in, and no longer requires an authentication check.

Parameters
string$userName

Definition at line 218 of file DAVServerTest.php.

218 {
219 $authBackend = new DAV\Auth\Backend\Mock();
220 $authBackend->setPrincipal('principals/' . $userName);
221 $this->authPlugin = new DAV\Auth\Plugin($authBackend);
222
223 // If the auth plugin already exists, we're removing its hooks:
224 if ($oldAuth = $this->server->getPlugin('auth')) {
225 $this->server->removeListener('beforeMethod', [$oldAuth, 'beforeMethod']);
226 }
227 $this->server->addPlugin($this->authPlugin);
228
229 // This will trigger the actual login procedure
230 $this->authPlugin->beforeMethod(new Request(), new Response());
231 }
$authBackend

References $authBackend.

◆ initializeEverything()

Sabre\DAVServerTest::initializeEverything ( )

Definition at line 117 of file DAVServerTest.php.

117 {
118
119 $this->setUpBackends();
120 $this->setUpTree();
121
122 $this->server = new DAV\Server($this->tree);
123 $this->server->sapi = new HTTP\SapiMock();
124 $this->server->debugExceptions = true;
125
126 if ($this->setupCalDAV) {
127 $this->caldavPlugin = new CalDAV\Plugin();
128 $this->server->addPlugin($this->caldavPlugin);
129 }
130 if ($this->setupCalDAVSharing || $this->setupSharing) {
131 $this->sharingPlugin = new DAV\Sharing\Plugin();
132 $this->server->addPlugin($this->sharingPlugin);
133 }
134 if ($this->setupCalDAVSharing) {
135 $this->caldavSharingPlugin = new CalDAV\SharingPlugin();
136 $this->server->addPlugin($this->caldavSharingPlugin);
137 }
138 if ($this->setupCalDAVScheduling) {
139 $this->caldavSchedulePlugin = new CalDAV\Schedule\Plugin();
140 $this->server->addPlugin($this->caldavSchedulePlugin);
141 }
142 if ($this->setupCalDAVSubscriptions) {
143 $this->server->addPlugin(new CalDAV\Subscriptions\Plugin());
144 }
145 if ($this->setupCalDAVICSExport) {
146 $this->caldavICSExportPlugin = new CalDAV\ICSExportPlugin();
147 $this->server->addPlugin($this->caldavICSExportPlugin);
148 }
149 if ($this->setupCardDAV) {
150 $this->carddavPlugin = new CardDAV\Plugin();
151 $this->server->addPlugin($this->carddavPlugin);
152 }
153 if ($this->setupLocks) {
154 $this->locksPlugin = new DAV\Locks\Plugin(
155 $this->locksBackend
156 );
157 $this->server->addPlugin($this->locksPlugin);
158 }
159 if ($this->setupPropertyStorage) {
160 $this->propertyStoragePlugin = new DAV\PropertyStorage\Plugin(
161 $this->propertyStorageBackend
162 );
163 $this->server->addPlugin($this->propertyStoragePlugin);
164 }
165 if ($this->autoLogin) {
166 $this->autoLogin($this->autoLogin);
167 }
168 if ($this->setupACL) {
169 $this->aclPlugin = new DAVACL\Plugin();
170 if (!$this->autoLogin) {
171 $this->aclPlugin->allowUnauthenticatedAccess = false;
172 }
173 $this->aclPlugin->adminPrincipals = ['principals/admin'];
174 $this->server->addPlugin($this->aclPlugin);
175 }
176
177 }
autoLogin($userName)
This function takes a username and sets the server in a state where this user is logged in,...
setUpTree()
Override this to provide your own Tree for your test-case.

◆ request()

Sabre\DAVServerTest::request (   $request,
  $expectedStatus = null 
)

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.

If $expectedStatus is set, we'll compare it with the HTTP status of the returned response. If it doesn't match, we'll immediately fail the test.

Parameters
array | \Sabre\HTTP\Request$request
int$expectedStatus
Returns
\Sabre\HTTP\Response

Definition at line 193 of file DAVServerTest.php.

193 {
194
195 if (is_array($request)) {
196 $request = HTTP\Request::createFromServerArray($request);
197 }
198 $response = new HTTP\ResponseMock();
199
200 $this->server->httpRequest = $request;
201 $this->server->httpResponse = $response;
202 $this->server->exec();
203
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);
207 }
208 return $this->server->httpResponse;
209
210 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
$response

References $request, and $response.

Referenced by Sabre\CalDAV\ICSExportPluginTest\testBeforeMethod(), Sabre\CalDAV\JCalTransformTest\testCalendarQueryDepth0(), Sabre\CalDAV\JCalTransformTest\testCalendarQueryDepth1(), Sabre\CardDAV\VCFExportTest\testContentDisposition(), Sabre\CardDAV\VCFExportTest\testContentDispositionBadChars(), Sabre\DAV\HttpCopyTest\testCopyColl(), Sabre\DAV\HttpCopyTest\testCopyCollIntoSubtree(), Sabre\DAV\HttpCopyTest\testCopyCollToExisting(), Sabre\DAV\HttpCopyTest\testCopyCollToExistingOverwriteF(), Sabre\DAV\HttpCopyTest\testCopyCollToExistingOverwriteT(), Sabre\DAV\HttpCopyTest\testCopyCollToSelf(), Sabre\DAV\HttpCopyTest\testCopyFile(), Sabre\DAV\HttpCopyTest\testCopyFileNonExistantParent(), Sabre\DAV\HttpCopyTest\testCopyFileToExistinBlockedCreateDestination(), Sabre\DAV\HttpCopyTest\testCopyFileToExisting(), Sabre\DAV\HttpCopyTest\testCopyFileToExistingOverwriteBadValue(), Sabre\DAV\HttpCopyTest\testCopyFileToExistingOverwriteF(), Sabre\DAV\HttpCopyTest\testCopyFileToExistingOverwriteT(), Sabre\DAV\HttpCopyTest\testCopyFileToSelf(), Sabre\DAV\ServerRangeTest\testCrazyRange(), Sabre\DAV\HttpDeleteTest\testDelete(), Sabre\DAV\HttpDeleteTest\testDeleteDirectory(), Sabre\DAV\HttpDeleteTest\testDeleteNotFound(), Sabre\DAV\HttpDeleteTest\testDeletePreconditions(), Sabre\DAV\HttpDeleteTest\testDeletePreconditionsFailed(), Sabre\CalDAV\Schedule\DeliverNewEventTest\testDelivery(), Sabre\DAV\HttpHeadTest\testDoubleAuth(), Sabre\DAV\ServerRangeTest\testEndRange(), Sabre\CardDAV\VCFExportTest\testExport(), Sabre\DAV\HttpPutTest\testFinderPutFail(), Sabre\DAV\HttpPutTest\testFinderPutSuccess(), Sabre\CalDAV\JCalTransformTest\testGet(), Sabre\DAV\HttpGetTest\testGet(), Sabre\DAV\HttpGetTest\testGet404(), Sabre\DAV\HttpGetTest\testGet404_aswell(), Sabre\DAV\HttpGetTest\testGetCollection(), Sabre\DAV\HttpGetTest\testGetDoubleSlash(), Sabre\DAV\HttpGetTest\testGetHttp10(), Sabre\DAV\HttpGetTest\testGetStreaming(), Sabre\DAV\HttpHeadTest\testHEAD(), Sabre\DAV\HttpHeadTest\testHEADCollection(), Sabre\DAV\Sync\PluginTest\testIfConditions(), Sabre\DAV\Sync\PluginTest\testIfConditionsNoSyncToken(), Sabre\DAV\Sync\PluginTest\testIfConditionsNot(), Sabre\DAV\ServerRangeTest\testIfRangeEtag(), Sabre\DAV\ServerRangeTest\testIfRangeEtagIncorrect(), Sabre\DAV\ServerRangeTest\testIfRangeModificationDate(), Sabre\DAV\ServerRangeTest\testIfRangeModificationDateModified(), Sabre\CalDAV\SharingPluginTest\testInviteBadXML(), Sabre\CalDAV\SharingPluginTest\testInviteReply(), Sabre\CalDAV\SharingPluginTest\testInviteWrongUrl(), Sabre\CalDAV\Subscriptions\CreateSubscriptionTest\testMKCALENDAR(), Sabre\CalDAV\Subscriptions\CreateSubscriptionTest\testMKCOL(), Sabre\DAV\HttpMoveTest\testMove(), Sabre\DAV\HttpMoveTest\testMoveToExisting(), Sabre\DAV\HttpMoveTest\testMoveToExistingBlockedDeleteSource(), Sabre\DAV\HttpMoveTest\testMoveToExistingOverwriteF(), Sabre\DAV\HttpMoveTest\testMoveToExistingOverwriteT(), Sabre\DAV\HttpMoveTest\testMoveToSelf(), Sabre\CalDAV\JCalTransformTest\testMultiGet(), Sabre\DAV\ServerRangeTest\testNonSeekableStream(), Sabre\DAV\PartialUpdate\PluginTest\testPatchBadRange(), Sabre\DAV\PartialUpdate\PluginTest\testPatchNoContentType(), Sabre\DAV\PartialUpdate\PluginTest\testPatchNoEndRange(), Sabre\DAV\PartialUpdate\PluginTest\testPatchNoLength(), Sabre\DAV\PartialUpdate\PluginTest\testPatchNoRange(), Sabre\DAV\PartialUpdate\PluginTest\testPatchNotSupported(), Sabre\DAV\PartialUpdate\PluginTest\testPatchSuccess(), Sabre\DAVACL\PrincipalMatchTest\testPrincipalMatch(), Sabre\DAV\HTTPPreferParsingTest\testpropfindMinimal(), Sabre\DAV\HTTPPreferParsingTest\testproppatchMinimal(), Sabre\DAV\HTTPPreferParsingTest\testproppatchMinimalError(), Sabre\CalDAV\SharingPluginTest\testPublish(), Sabre\CalDAV\SharingPluginTest\testPublishWrongUrl(), Sabre\DAV\HttpPutTest\testPut(), Sabre\DAV\HttpPutTest\testPutContentRange(), Sabre\DAV\HttpPutTest\testPutExisting(), Sabre\DAV\HttpPutTest\testPutExistingIfMatchCorrect(), Sabre\DAV\HttpPutTest\testPutExistingIfMatchStar(), Sabre\DAV\HttpPutTest\testPutExistingIfNoneMatchStar(), Sabre\DAV\HttpPutTest\testPutIfMatchStar(), Sabre\DAV\HttpPutTest\testPutIfNoneMatchStar(), Sabre\DAV\HttpPutTest\testPutIntercept(), Sabre\DAV\HttpPutTest\testPutNoParent(), Sabre\DAV\ServerRangeTest\testRange(), Sabre\DAVACL\AclPrincipalPropSetReportTest\testReport(), Sabre\DAVACL\AclPrincipalPropSetReportTest\testReportDepth1(), Sabre\CalDAV\SharingPluginTest\testShareRequest(), Sabre\CalDAV\SharingPluginTest\testShareRequestNoShareableCalendar(), Sabre\DAV\Sharing\ShareResourceTest\testShareResource(), Sabre\DAV\Sharing\ShareResourceTest\testShareResourceInviteProperty(), Sabre\DAV\Sharing\ShareResourceTest\testShareResourceNotFound(), Sabre\DAV\Sharing\ShareResourceTest\testShareResourceNotISharedNode(), Sabre\DAV\Sharing\ShareResourceTest\testShareResourceRemoveAccess(), Sabre\DAV\Sharing\ShareResourceTest\testShareResourceUnknownDoc(), Sabre\DAV\ServerRangeTest\testStartRange(), Sabre\DAV\Sync\PluginTest\testSubsequentSyncSyncCollection(), Sabre\DAV\Sync\PluginTest\testSubsequentSyncSyncCollectionDepthFallBack(), Sabre\DAV\Sync\PluginTest\testSubsequentSyncSyncCollectionLimit(), Sabre\DAV\Sync\PluginTest\testSyncInitialSyncCollection(), Sabre\DAV\Sync\PluginTest\testSyncInvalidToken(), Sabre\DAV\Sync\PluginTest\testSyncInvalidTokenNoPrefix(), Sabre\DAV\Sync\PluginTest\testSyncNoProp(), Sabre\DAV\Sync\PluginTest\testSyncNoSyncCollection(), Sabre\DAV\Sync\PluginTest\testSyncNoSyncInfo(), Sabre\DAV\Sync\PluginTest\testSyncNoSyncToken(), Sabre\DAV\ServerRangeTest\testTooHighRange(), Sabre\CalDAV\SharingPluginTest\testUnknownMethodNoNode(), Sabre\CalDAV\SharingPluginTest\testUnknownMethodNoPOST(), Sabre\CalDAV\SharingPluginTest\testUnknownMethodNoXML(), Sabre\CalDAV\SharingPluginTest\testUnknownXmlDoc(), Sabre\DAV\Locks\Plugin2Test\testUnlockAfterDelete(), Sabre\CalDAV\SharingPluginTest\testUnpublish(), and Sabre\CalDAV\SharingPluginTest\testUnpublishWrongUrl().

+ Here is the caller graph for this function:

◆ setUp()

◆ setUpBackends()

Sabre\DAVServerTest::setUpBackends ( )

Definition at line 268 of file DAVServerTest.php.

268 {
269
270 if ($this->setupCalDAVSharing && is_null($this->caldavBackend)) {
271 $this->caldavBackend = new CalDAV\Backend\MockSharing($this->caldavCalendars, $this->caldavCalendarObjects);
272 }
273 if ($this->setupCalDAVSubscriptions && is_null($this->caldavBackend)) {
274 $this->caldavBackend = new CalDAV\Backend\MockSubscriptionSupport($this->caldavCalendars, $this->caldavCalendarObjects);
275 }
276 if ($this->setupCalDAV && is_null($this->caldavBackend)) {
277 if ($this->setupCalDAVScheduling) {
278 $this->caldavBackend = new CalDAV\Backend\MockScheduling($this->caldavCalendars, $this->caldavCalendarObjects);
279 } else {
280 $this->caldavBackend = new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects);
281 }
282 }
283 if ($this->setupCardDAV && is_null($this->carddavBackend)) {
284 $this->carddavBackend = new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards);
285 }
286 if ($this->setupCardDAV || $this->setupCalDAV || $this->setupACL) {
287 $this->principalBackend = new DAVACL\PrincipalBackend\Mock();
288 }
289 if ($this->setupLocks) {
290 $this->locksBackend = new DAV\Locks\Backend\Mock();
291 }
292 if ($this->setupPropertyStorage) {
293 $this->propertyStorageBackend = new DAV\PropertyStorage\Backend\Mock();
294 }
295
296 }

◆ setUpTree()

Sabre\DAVServerTest::setUpTree ( )

Override this to provide your own Tree for your test-case.

Reimplemented in Sabre\DAV\HttpCopyTest, Sabre\DAV\HttpDeleteTest, Sabre\DAV\HttpGetTest, Sabre\DAV\HttpHeadTest, Sabre\DAV\HttpMoveTest, Sabre\DAV\HttpPutTest, Sabre\DAV\Locks\Plugin2Test, Sabre\DAV\Sharing\PluginTest, Sabre\DAV\Sharing\ShareResourceTest, and Sabre\DAV\Sync\PluginTest.

Definition at line 236 of file DAVServerTest.php.

236 {
237
238 if ($this->setupCalDAV) {
239 $this->tree[] = new CalDAV\CalendarRoot(
240 $this->principalBackend,
241 $this->caldavBackend
242 );
243 }
244 if ($this->setupCardDAV) {
245 $this->tree[] = new CardDAV\AddressBookRoot(
246 $this->principalBackend,
247 $this->carddavBackend
248 );
249 }
250
251 if ($this->setupCalDAV) {
252 $this->tree[] = new CalDAV\Principal\Collection(
253 $this->principalBackend
254 );
255 } elseif ($this->setupCardDAV || $this->setupACL) {
256 $this->tree[] = new DAVACL\PrincipalCollection(
257 $this->principalBackend
258 );
259 }
260 if ($this->setupFiles) {
261
262 $this->tree[] = new DAV\Mock\Collection('files');
263
264 }
265
266 }

Field Documentation

◆ $aclPlugin

Sabre\DAVServerTest::$aclPlugin
protected

Definition at line 69 of file DAVServerTest.php.

◆ $authPlugin

Sabre\DAVServerTest::$authPlugin
protected

Definition at line 86 of file DAVServerTest.php.

◆ $autoLogin

Sabre\DAVServerTest::$autoLogin = null
protected

If this string is set, we will automatically log in the user with this name.

Definition at line 109 of file DAVServerTest.php.

◆ $caldavBackend

Sabre\DAVServerTest::$caldavBackend
protected

Definition at line 50 of file DAVServerTest.php.

◆ $caldavCalendarObjects

Sabre\DAVServerTest::$caldavCalendarObjects = []
protected

Definition at line 39 of file DAVServerTest.php.

◆ $caldavCalendars

Sabre\DAVServerTest::$caldavCalendars = []
protected

An array with calendars.

Every calendar should have

  • principaluri
  • uri

Definition at line 38 of file DAVServerTest.php.

◆ $caldavPlugin

Sabre\DAVServerTest::$caldavPlugin
protected

Definition at line 59 of file DAVServerTest.php.

◆ $caldavSchedulePlugin

Sabre\DAVServerTest::$caldavSchedulePlugin
protected

Definition at line 81 of file DAVServerTest.php.

◆ $caldavSharingPlugin

Sabre\DAVServerTest::$caldavSharingPlugin
protected

Definition at line 74 of file DAVServerTest.php.

◆ $carddavAddressBooks

Sabre\DAVServerTest::$carddavAddressBooks = []
protected

Definition at line 41 of file DAVServerTest.php.

◆ $carddavBackend

Sabre\DAVServerTest::$carddavBackend
protected

Definition at line 51 of file DAVServerTest.php.

◆ $carddavCards

Sabre\DAVServerTest::$carddavCards = []
protected

Definition at line 42 of file DAVServerTest.php.

◆ $carddavPlugin

Sabre\DAVServerTest::$carddavPlugin
protected

Definition at line 64 of file DAVServerTest.php.

◆ $locksBackend

Sabre\DAVServerTest::$locksBackend
protected

Definition at line 53 of file DAVServerTest.php.

◆ $locksPlugin

Sabre\DAVServerTest::$locksPlugin
protected

Definition at line 91 of file DAVServerTest.php.

◆ $principalBackend

Sabre\DAVServerTest::$principalBackend
protected

Definition at line 52 of file DAVServerTest.php.

◆ $propertyStorageBackend

Sabre\DAVServerTest::$propertyStorageBackend
protected

Definition at line 54 of file DAVServerTest.php.

◆ $propertyStoragePlugin

Sabre\DAVServerTest::$propertyStoragePlugin
protected

Definition at line 103 of file DAVServerTest.php.

◆ $server

◆ $setupACL

Sabre\DAVServerTest::$setupACL = false
protected

Definition at line 23 of file DAVServerTest.php.

◆ $setupCalDAV

Sabre\DAVServerTest::$setupCalDAV = false
protected

Definition at line 21 of file DAVServerTest.php.

◆ $setupCalDAVICSExport

Sabre\DAVServerTest::$setupCalDAVICSExport = false
protected

Definition at line 27 of file DAVServerTest.php.

◆ $setupCalDAVScheduling

Sabre\DAVServerTest::$setupCalDAVScheduling = false
protected

Definition at line 25 of file DAVServerTest.php.

◆ $setupCalDAVSharing

Sabre\DAVServerTest::$setupCalDAVSharing = false
protected

Definition at line 24 of file DAVServerTest.php.

◆ $setupCalDAVSubscriptions

Sabre\DAVServerTest::$setupCalDAVSubscriptions = false
protected

Definition at line 26 of file DAVServerTest.php.

◆ $setupCardDAV

Sabre\DAVServerTest::$setupCardDAV = false
protected

Definition at line 22 of file DAVServerTest.php.

◆ $setupFiles

Sabre\DAVServerTest::$setupFiles = false
protected

Definition at line 29 of file DAVServerTest.php.

◆ $setupLocks

Sabre\DAVServerTest::$setupLocks = false
protected

Definition at line 28 of file DAVServerTest.php.

◆ $setupPropertyStorage

Sabre\DAVServerTest::$setupPropertyStorage = false
protected

Definition at line 31 of file DAVServerTest.php.

◆ $setupSharing

Sabre\DAVServerTest::$setupSharing = false
protected

Definition at line 30 of file DAVServerTest.php.

◆ $sharingPlugin

Sabre\DAVServerTest::$sharingPlugin
protected

Definition at line 98 of file DAVServerTest.php.

◆ $tree

Sabre\DAVServerTest::$tree = []
protected

Definition at line 48 of file DAVServerTest.php.


The documentation for this class was generated from the following file: