7 require_once
'Sabre/HTTP/ResponseMock.php';
8 require_once
'Sabre/DAV/AbstractServer.php';
20 if (file_exists(SABRE_TEMPDIR .
'../.sabredav')) unlink(SABRE_TEMPDIR .
'../.sabredav');
22 file_put_contents(SABRE_TEMPDIR .
'/test2.txt',
'Test contents2');
23 mkdir(SABRE_TEMPDIR .
'/col');
24 file_put_contents(SABRE_TEMPDIR .
'col/test.txt',
'Test contents');
25 $this->server->addPlugin(
new Locks\Plugin(
new Locks\Backend\
File(SABRE_TEMPDIR .
'/.locksdb')));
32 if (file_exists(SABRE_TEMPDIR .
'../.locksdb')) unlink(SABRE_TEMPDIR .
'../.locksdb');
38 $request =
new HTTP\Request(
'PROPFIND',
$path, $headers, $body);
40 $this->server->httpRequest =
$request;
41 $this->server->exec();
48 $this->assertEquals(207, $this->response->status);
52 'Content-Type' => [
'application/xml; charset=utf-8'],
53 'DAV' => [
'1, 3, extended-mkcol, 2'],
54 'Vary' => [
'Brief,Prefer'],
56 $this->response->getHeaders()
59 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
60 $xml = simplexml_load_string($body);
61 $xml->registerXPathNamespace(
'd',
'urn:DAV');
63 list(
$data) =
$xml->xpath(
'/d:multistatus/d:response/d:href');
64 $this->assertEquals(
'/', (
string)
$data,
'href element should have been /');
66 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype');
67 $this->assertEquals(1, count($data));
74 $this->assertEquals(207, $this->response->status);
78 'Content-Type' => [
'application/xml; charset=utf-8'],
79 'DAV' => [
'1, 3, extended-mkcol, 2'],
80 'Vary' => [
'Brief,Prefer'],
82 $this->response->getHeaders()
85 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
86 $xml = simplexml_load_string($body);
87 $xml->registerXPathNamespace(
'd',
'urn:DAV');
89 list(
$data) =
$xml->xpath(
'/d:multistatus/d:response/d:href');
90 $this->assertEquals(
'/test2.txt', (
string)
$data,
'href element should have been /test2.txt');
92 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength');
93 $this->assertEquals(1, count($data));
99 $xml =
'<?xml version="1.0"?> 100 <d:propfind xmlns:d="DAV:"> 108 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
109 $xml = simplexml_load_string($body);
110 $xml->registerXPathNamespace(
'd',
'urn:DAV');
112 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry');
113 $this->assertEquals(2, count(
$data),
'We expected two \'d:lockentry\' tags');
115 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope');
116 $this->assertEquals(2, count(
$data),
'We expected two \'d:lockscope\' tags');
118 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype');
119 $this->assertEquals(2, count(
$data),
'We expected two \'d:locktype\' tags');
121 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:shared');
122 $this->assertEquals(1, count(
$data),
'We expected a \'d:shared\' tag');
124 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:exclusive');
125 $this->assertEquals(1, count(
$data),
'We expected a \'d:exclusive\' tag');
127 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype/d:write');
128 $this->assertEquals(2, count(
$data),
'We expected two \'d:write\' tags');
133 $xml =
'<?xml version="1.0"?> 134 <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');
146 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery');
147 $this->assertEquals(1, count(
$data),
'We expected a \'d:lockdiscovery\' tag');
153 $xml =
'<?xml version="1.0"?> 154 <d:propfind xmlns:d="DAV:"> 161 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
162 $xml = simplexml_load_string($body);
163 $xml->registerXPathNamespace(
'd',
'urn:DAV');
166 '/d:multistatus/d:response',
167 '/d:multistatus/d:response/d:propstat',
168 '/d:multistatus/d:response/d:propstat/d:status',
169 '/d:multistatus/d:response/d:propstat/d:prop',
170 '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni',
172 foreach ($pathTests as
$test) {
173 $this->assertTrue(count(
$xml->xpath($test)) ==
true,
'We expected the ' . $test .
' element to appear in the response, we got: ' . $body);
176 $val =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:status');
177 $this->assertEquals(1, count($val), $body);
178 $this->assertEquals(
'HTTP/1.1 404 Not Found', (
string)$val[0]);
184 $body =
'<?xml version="1.0"?> 185 <d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test"> 186 <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set> 187 <d:remove><d:prop><s:someprop2 /></d:prop></d:remove> 188 <d:set><d:prop><s:someprop3>removeme</s:someprop3></d:prop></d:set> 189 <d:remove><d:prop><s:someprop3 /></d:prop></d:remove> 190 </d:propertyupdate>';
192 $result = $this->server->xml->parse($body);
193 $this->assertEquals([
194 '{http://sabredav.org/NS/test}someprop' =>
'somevalue',
195 '{http://sabredav.org/NS/test}someprop2' => null,
196 '{http://sabredav.org/NS/test}someprop3' => null,
const VERSION
Full version number.
testParsePropPatchRequest()
sendRequest($body, $path='/', $headers=['Depth'=> '0'])
testPropFindEmptyBodyFile()