Skip to content

Commit

Permalink
Add test case for custom property with Depth 1
Browse files Browse the repository at this point in the history
  • Loading branch information
n-peugnet authored and phil-davis committed Nov 16, 2021
1 parent 1e948a8 commit 7f5d88f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Sabre/DAV/ServerPropsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,38 @@ public function testPropFindEmptyBody()
$this->assertEquals(1, count($data));
}

public function testPropFindEmptyBodyDepth1Custom()
{
// Add custom property to nodes.
$this->server->on('propFind', function (PropFind $propFind, INode $node) {
$propFind->set('{DAV:}ishidden', '1');
});

$this->sendRequest('', '/', ['Depth' => 1]);
$this->assertEquals(207, $this->response->status);

$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
'Content-Type' => ['application/xml; charset=utf-8'],
'DAV' => ['1, 3, extended-mkcol, 2'],
'Vary' => ['Brief,Prefer'],
],
$this->response->getHeaders()
);

$body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString());
$xml = simplexml_load_string($body);
$xml->registerXPathNamespace('d', 'urn:DAV');

$data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:ishidden');
$this->assertEquals(5, count($data), 'Response should contain 5 elements');

$data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:ishidden');
foreach ($data as $prop) {
$this->assertEquals('1', $prop[0]);
}
}

public function testPropFindEmptyBodyFile()
{
$this->sendRequest('', '/test2.txt', []);
Expand Down

0 comments on commit 7f5d88f

Please sign in to comment.