7 require_once
'Sabre/DAV/AbstractServer.php';
19 if (file_exists(SABRE_TEMPDIR .
'../.sabredav')) unlink(SABRE_TEMPDIR .
'../.sabredav');
21 file_put_contents(SABRE_TEMPDIR .
'/test2.txt',
'Test contents2');
22 mkdir(SABRE_TEMPDIR .
'/col');
23 mkdir(SABRE_TEMPDIR .
'/col/col');
24 file_put_contents(SABRE_TEMPDIR .
'col/col/test.txt',
'Test contents');
25 $this->server->addPlugin(
new Locks\Plugin(
new Locks\Backend\
File(SABRE_TEMPDIR .
'/.locksdb')));
26 $this->server->enablePropfindDepthInfinity =
true;
33 if (file_exists(SABRE_TEMPDIR .
'../.locksdb')) unlink(SABRE_TEMPDIR .
'../.locksdb');
39 $request =
new HTTP\Request(
'PROPFIND',
'/', [
'Depth' =>
'infinity']);
42 $this->server->httpRequest =
$request;
43 $this->server->exec();
51 $this->assertEquals(207, $this->response->status,
'Incorrect status received. Full response body: ' . $this->response->getBodyAsString());
55 'Content-Type' => [
'application/xml; charset=utf-8'],
56 'DAV' => [
'1, 3, extended-mkcol, 2'],
57 'Vary' => [
'Brief,Prefer'],
59 $this->response->getHeaders()
62 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
63 $xml = simplexml_load_string($body);
64 $xml->registerXPathNamespace(
'd',
'urn:DAV');
66 list(
$data) =
$xml->xpath(
'/d:multistatus/d:response/d:href');
67 $this->assertEquals(
'/', (
string)
$data,
'href element should have been /');
69 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype');
71 $this->assertEquals(8, count($data));
77 $xml =
'<?xml version="1.0"?> 78 <d:propfind xmlns:d="DAV:"> 86 $body = $this->response->getBodyAsString();
87 $this->assertEquals(207, $this->response->getStatus(), $body);
89 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $body);
90 $xml = simplexml_load_string($body);
91 $xml->registerXPathNamespace(
'd',
'urn:DAV');
93 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry');
94 $this->assertEquals(16, count(
$data),
'We expected sixteen \'d:lockentry\' tags');
96 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope');
97 $this->assertEquals(16, count(
$data),
'We expected sixteen \'d:lockscope\' tags');
99 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype');
100 $this->assertEquals(16, count(
$data),
'We expected sixteen \'d:locktype\' tags');
102 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:shared');
103 $this->assertEquals(8, count(
$data),
'We expected eight \'d:shared\' tags');
105 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:exclusive');
106 $this->assertEquals(8, count(
$data),
'We expected eight \'d:exclusive\' tags');
108 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype/d:write');
109 $this->assertEquals(16, count(
$data),
'We expected sixteen \'d:write\' tags');
114 $xml =
'<?xml version="1.0"?> 115 <d:propfind xmlns:d="DAV:"> 123 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
124 $xml = simplexml_load_string($body);
125 $xml->registerXPathNamespace(
'd',
'urn:DAV');
127 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery');
128 $this->assertEquals(8, count(
$data),
'We expected eight \'d:lockdiscovery\' tags');
134 $xml =
'<?xml version="1.0"?> 135 <d:propfind xmlns:d="DAV:"> 142 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
143 $xml = simplexml_load_string($body);
144 $xml->registerXPathNamespace(
'd',
'urn:DAV');
147 '/d:multistatus/d:response',
148 '/d:multistatus/d:response/d:propstat',
149 '/d:multistatus/d:response/d:propstat/d:status',
150 '/d:multistatus/d:response/d:propstat/d:prop',
151 '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni',
153 foreach ($pathTests as
$test) {
154 $this->assertTrue(count(
$xml->xpath($test)) ==
true,
'We expected the ' . $test .
' element to appear in the response, we got: ' . $body);
157 $val =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:status');
158 $this->assertEquals(8, count($val), $body);
159 $this->assertEquals(
'HTTP/1.1 404 Not Found', (
string)$val[0]);
const VERSION
Full version number.