From 78fb93777f746be02589ed47ab8af12b42062e7a Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 20 May 2021 13:46:41 +0200 Subject: [PATCH] Add test case for custom property with Depth 1 --- tests/Sabre/DAV/ServerPropsTest.php | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/Sabre/DAV/ServerPropsTest.php b/tests/Sabre/DAV/ServerPropsTest.php index cd1ccfa534..dde7ccfa87 100644 --- a/tests/Sabre/DAV/ServerPropsTest.php +++ b/tests/Sabre/DAV/ServerPropsTest.php @@ -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', []);