diff --git a/apps/dav/tests/unit/DAV/FileCustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/FileCustomPropertiesBackendTest.php
index 5ee8bd6e4f4e..c3ef2c213294 100644
--- a/apps/dav/tests/unit/DAV/FileCustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/DAV/FileCustomPropertiesBackendTest.php
@@ -36,6 +36,7 @@
use OCP\Files\Node;
use Sabre\DAV\PropFind;
use Sabre\DAV\SimpleCollection;
+use Sabre\DAV\Xml\Property\Complex;
/**
* Class FileCustomPropertiesBackendTest
@@ -146,6 +147,7 @@ private function applyDefaultProps($path = '/dummypath') {
$propPatch = new \Sabre\DAV\PropPatch([
'customprop' => 'value1',
'customprop2' => 'value2',
+ 'customprop3' => new Complex('')
]);
$this->backend->propPatch(
@@ -253,6 +255,7 @@ public function testSetGetPropertiesForFile() {
[
'customprop',
'customprop2',
+ 'customprop3',
'unsetprop',
],
0
@@ -265,6 +268,10 @@ public function testSetGetPropertiesForFile() {
$this->assertEquals('value1', $propFind->get('customprop'));
$this->assertEquals('value2', $propFind->get('customprop2'));
+ /** @var Complex $complexProp */
+ $complexProp = $propFind->get('customprop3');
+ $this->assertInstanceOf(Complex::class, $complexProp);
+ $this->assertEquals('', $complexProp->getXml());
$this->assertEquals(['unsetprop'], $propFind->get404Properties());
}
diff --git a/tests/acceptance/features/apiWebdavProperties/setFileProperties.feature b/tests/acceptance/features/apiWebdavProperties/setFileProperties.feature
index f76b26f3ed51..29ebfac0d1e0 100644
--- a/tests/acceptance/features/apiWebdavProperties/setFileProperties.feature
+++ b/tests/acceptance/features/apiWebdavProperties/setFileProperties.feature
@@ -25,7 +25,7 @@ Feature: set file properties
And user "user0" has uploaded file "filesForUpload/textfile.txt" to "/testcustomprop.txt"
And user "user0" has set property "very-custom-prop" with namespace "x1='http://whatever.org/ns'" of file "/testcustomprop.txt" to ""
When user "user0" gets a custom property "very-custom-prop" with namespace "x1='http://whatever.org/ns'" of file "/testcustomprop.txt"
- Then the response should contain a custom "very-custom-prop" property with namespace "x1='http://whatever.org/ns'" and value ""
+ Then the response should contain a custom "very-custom-prop" property with namespace "x1='http://whatever.org/ns'" and complex value ""
Examples:
| dav_version |
| old |
diff --git a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php
index 004c2c6eb148..2123869cf4ed 100644
--- a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php
+++ b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php
@@ -347,6 +347,46 @@ public function theResponseShouldContainACustomPropertyWithValue(
);
}
+ /**
+ * @Then /^the response should contain a custom "([^"]*)" property with namespace "([^"]*)" and complex value "(([^"\\]|\\.)*)"$/
+ *
+ * @param string $propertyName
+ * @param string $namespaceString
+ * @param string $propertyValue
+ *
+ * @return void
+ * @throws \Exception
+ */
+ public function theResponseShouldContainACustomPropertyWithComplexValue(
+ $propertyName, $namespaceString, $propertyValue
+ ) {
+ // let's unescape quotes first
+ $propertyValue = \str_replace('\"', '"', $propertyValue);
+ $this->featureContext->setResponseXmlObject(
+ HttpRequestHelper::getResponseXml($this->featureContext->getResponse())
+ );
+ $responseXmlObject = $this->featureContext->getResponseXmlObject();
+ //calculate the namespace prefix and namespace
+ $matches = [];
+ \preg_match("/^(.*)='(.*)'$/", $namespaceString, $matches);
+ $nameSpace = $matches[2];
+ $nameSpacePrefix = $matches[1];
+ $responseXmlObject->registerXPathNamespace(
+ $nameSpacePrefix, $nameSpace
+ );
+ $xmlPart = $responseXmlObject->xpath(
+ "//d:prop/" . "$nameSpacePrefix:$propertyName" . "/*"
+ );
+ Assert::assertArrayHasKey(
+ 0, $xmlPart, "Cannot find property \"$propertyName\""
+ );
+ Assert::assertEquals(
+ $propertyValue, $xmlPart[0]->asXML(),
+ "\"$propertyName\" has a value \"" .
+ $xmlPart[0]->asXML() . "\" but \"$propertyValue\" expected"
+ );
+ }
+
/**
* @Then the single response should contain a property :property with a child property :childProperty
*