8 require_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();
24 $plugin->allowUnauthenticatedAccess =
false;
25 $this->assertTrue($plugin instanceof
Plugin);
26 $fakeServer->addPlugin($plugin);
27 $this->assertEquals($plugin, $fakeServer->getPlugin(
'acl'));
35 $xml =
'<?xml version="1.0"?> 36 <d:principal-search-property-set xmlns:d="DAV:" />';
39 'REQUEST_METHOD' =>
'REPORT',
41 'REQUEST_URI' =>
'/principals',
52 $this->assertEquals(400,
$server->httpResponse->status);
55 'Content-Type' => [
'application/xml; charset=utf-8'],
56 ],
$server->httpResponse->getHeaders());
62 $xml =
'<?xml version="1.0"?> 63 <d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>';
66 'REQUEST_METHOD' =>
'REPORT',
68 'REQUEST_URI' =>
'/principals',
79 $this->assertEquals(400,
$server->httpResponse->status,
$server->httpResponse->body);
82 'Content-Type' => [
'application/xml; charset=utf-8'],
83 ],
$server->httpResponse->getHeaders());
89 $xml =
'<?xml version="1.0"?> 90 <d:principal-search-property-set xmlns:d="DAV:"/>';
93 'REQUEST_METHOD' =>
'REPORT',
95 'REQUEST_URI' =>
'/principals',
106 $this->assertEquals(200,
$server->httpResponse->status,
$server->httpResponse->body);
107 $this->assertEquals([
109 'Content-Type' => [
'application/xml; charset=utf-8'],
110 ],
$server->httpResponse->getHeaders());
114 '/d:principal-search-property-set',
115 '/d:principal-search-property-set/d:principal-search-property' => 2,
116 '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2,
117 '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1,
118 '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1,
119 '/d:principal-search-property-set/d:principal-search-property/d:description' => 2,
122 $xml = simplexml_load_string(
$server->httpResponse->body);
123 $xml->registerXPathNamespace(
'd',
'DAV:');
124 $xml->registerXPathNamespace(
's',
'http://sabredav.org/ns');
125 foreach ($check as $v1 => $v2) {
127 $xpath = is_int($v1) ? $v2 : $v1;
132 if (!is_int($v1)) $count = $v2;
134 $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
const VERSION
Full version number.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.