8require_once
'Sabre/HTTP/ResponseMock.php';
14 $backend =
new PrincipalBackend\Mock();
18 $dir->addChild($principals);
21 $fakeServer->sapi =
new HTTP\SapiMock();
22 $fakeServer->httpResponse =
new HTTP\ResponseMock();
23 $fakeServer->debugExceptions =
true;
25 $plugin->allowAccessToNodesWithoutACL =
true;
26 $plugin->allowUnauthenticatedAccess =
false;
28 $this->assertTrue($plugin instanceof
Plugin);
29 $fakeServer->addPlugin($plugin);
30 $this->assertEquals($plugin, $fakeServer->getPlugin(
'acl'));
38 $xml =
'<?xml version="1.0"?>
39<d:principal-property-search xmlns:d="DAV:">
44 <d:match>user</d:match>
48 <d:getcontentlength />
50</d:principal-property-search>';
53 'REQUEST_METHOD' =>
'REPORT',
55 'REQUEST_URI' =>
'/principals',
66 $this->assertEquals(400,
$server->httpResponse->getStatus(),
$server->httpResponse->getBodyAsString());
69 'Content-Type' => [
'application/xml; charset=utf-8'],
70 ],
$server->httpResponse->getHeaders());
77 $xml =
'<?xml version="1.0"?>
78<d:principal-property-search xmlns:d="DAV:">
83 <d:match>user</d:match>
87 <d:getcontentlength />
89</d:principal-property-search>';
92 'REQUEST_METHOD' =>
'REPORT',
94 'REQUEST_URI' =>
'/principals',
105 $this->assertEquals(207,
$server->httpResponse->getStatus(),
"Full body: " .
$server->httpResponse->getBodyAsString());
106 $this->assertEquals([
108 'Content-Type' => [
'application/xml; charset=utf-8'],
109 'Vary' => [
'Brief,Prefer'],
110 ],
$server->httpResponse->getHeaders());
116 $xml =
'<?xml version="1.0"?>
117<d:principal-property-search xmlns:d="DAV:">
118 <d:apply-to-principal-collection-set />
123 <d:match>user</d:match>
127 <d:getcontentlength />
129</d:principal-property-search>';
132 'REQUEST_METHOD' =>
'REPORT',
134 'REQUEST_URI' =>
'/',
145 $this->assertEquals(207,
$server->httpResponse->status,
$server->httpResponse->body);
146 $this->assertEquals([
148 'Content-Type' => [
'application/xml; charset=utf-8'],
149 'Vary' => [
'Brief,Prefer'],
150 ],
$server->httpResponse->getHeaders());
155 '/d:multistatus/d:response' => 2,
156 '/d:multistatus/d:response/d:href' => 2,
157 '/d:multistatus/d:response/d:propstat' => 4,
158 '/d:multistatus/d:response/d:propstat/d:prop' => 4,
159 '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2,
160 '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2,
161 '/d:multistatus/d:response/d:propstat/d:status' => 4,
164 $xml = simplexml_load_string(
$server->httpResponse->body);
165 $xml->registerXPathNamespace(
'd',
'DAV:');
166 foreach ($check as $v1 => $v2) {
168 $xpath = is_int($v1) ? $v2 : $v1;
173 if (!is_int($v1)) $count = $v2;
175 $this->assertEquals($count, count(
$result),
'we expected ' . $count .
' appearances of ' . $xpath .
' . We found ' . count(
$result) .
'. Full response body: ' .
$server->httpResponse->body);
183 $xml =
'<?xml version="1.0"?>
184<d:principal-property-search xmlns:d="DAV:">
185 <d:apply-to-principal-collection-set />
190 <d:match>user</d:match>
196 <d:match>bar</d:match>
200 <d:getcontentlength />
202</d:principal-property-search>';
205 'REQUEST_METHOD' =>
'REPORT',
207 'REQUEST_URI' =>
'/',
218 $this->assertEquals(207,
$server->httpResponse->status,
$server->httpResponse->body);
219 $this->assertEquals([
221 'Content-Type' => [
'application/xml; charset=utf-8'],
222 'Vary' => [
'Brief,Prefer'],
223 ],
$server->httpResponse->getHeaders());
228 '/d:multistatus/d:response' => 0,
229 '/d:multistatus/d:response/d:href' => 0,
230 '/d:multistatus/d:response/d:propstat' => 0,
231 '/d:multistatus/d:response/d:propstat/d:prop' => 0,
232 '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0,
233 '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0,
234 '/d:multistatus/d:response/d:propstat/d:status' => 0,
237 $xml = simplexml_load_string(
$server->httpResponse->body);
238 $xml->registerXPathNamespace(
'd',
'DAV:');
239 foreach ($check as $v1 => $v2) {
241 $xpath = is_int($v1) ? $v2 : $v1;
246 if (!is_int($v1)) $count = $v2;
248 $this->assertEquals($count, count(
$result),
'we expected ' . $count .
' appearances of ' . $xpath .
' . We found ' . count(
$result) .
'. Full response body: ' .
$server->httpResponse->body);
255 $xml =
'<?xml version="1.0"?>
256<d:principal-property-search xmlns:d="DAV:" test="anyof">
257 <d:apply-to-principal-collection-set />
262 <d:match>user</d:match>
268 <d:match>bar</d:match>
272 <d:getcontentlength />
274</d:principal-property-search>';
277 'REQUEST_METHOD' =>
'REPORT',
279 'REQUEST_URI' =>
'/',
290 $this->assertEquals(207,
$server->httpResponse->status,
$server->httpResponse->body);
291 $this->assertEquals([
293 'Content-Type' => [
'application/xml; charset=utf-8'],
294 'Vary' => [
'Brief,Prefer'],
295 ],
$server->httpResponse->getHeaders());
300 '/d:multistatus/d:response' => 2,
301 '/d:multistatus/d:response/d:href' => 2,
302 '/d:multistatus/d:response/d:propstat' => 4,
303 '/d:multistatus/d:response/d:propstat/d:prop' => 4,
304 '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2,
305 '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2,
306 '/d:multistatus/d:response/d:propstat/d:status' => 4,
309 $xml = simplexml_load_string(
$server->httpResponse->body);
310 $xml->registerXPathNamespace(
'd',
'DAV:');
311 foreach ($check as $v1 => $v2) {
313 $xpath = is_int($v1) ? $v2 : $v1;
318 if (!is_int($v1)) $count = $v2;
320 $this->assertEquals($count, count(
$result),
'we expected ' . $count .
' appearances of ' . $xpath .
' . We found ' . count(
$result) .
'. Full response body: ' .
$server->httpResponse->body);
327 $xml =
'<?xml version="1.0"?>
328<d:principal-property-search xmlns:d="DAV:">
333 <d:match>user</d:match>
337 <d:getcontentlength />
339</d:principal-property-search>';
342 'REQUEST_METHOD' =>
'REPORT',
344 'REQUEST_URI' =>
'/',
355 $this->assertEquals(207,
$server->httpResponse->status,
$server->httpResponse->body);
356 $this->assertEquals([
358 'Content-Type' => [
'application/xml; charset=utf-8'],
359 'Vary' => [
'Brief,Prefer'],
360 ],
$server->httpResponse->getHeaders());
365 '/d:multistatus/d:response' => 0,
368 $xml = simplexml_load_string(
$server->httpResponse->body);
369 $xml->registerXPathNamespace(
'd',
'DAV:');
370 foreach ($check as $v1 => $v2) {
372 $xpath = is_int($v1) ? $v2 : $v1;
377 if (!is_int($v1)) $count = $v2;
379 $this->assertEquals($count, count(
$result),
'we expected ' . $count .
' appearances of ' . $xpath .
' . We found ' . count(
$result) .
'. Full response body: ' .
$server->httpResponse->body);
foreach($paths as $path) $request
An exception for terminatinating execution or to throw for unit testing.
getCurrentUserPrivilegeSet($node)
Returns a list of privileges the current user has on a particular node.
const VERSION
Full version number.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.