diff --git a/lib/private/legacy/api.php b/lib/private/legacy/api.php index 6436d8479824..a69c9892e6a5 100644 --- a/lib/private/legacy/api.php +++ b/lib/private/legacy/api.php @@ -436,7 +436,13 @@ public static function respond($result, $format='xml') { private static function toXML($array, $writer) { foreach($array as $k => $v) { if ($k[0] === '@') { - $writer->writeAttribute(substr($k, 1), $v); + if (is_array($v)) { + foreach ($v as $name => $value) { + $writer->writeAttribute($name, $value); + } + } else { + $writer->writeAttribute(substr($k, 1), $v); + } continue; } else if (is_numeric($k)) { $k = 'element'; diff --git a/tests/integration/features/bootstrap/BasicStructure.php b/tests/integration/features/bootstrap/BasicStructure.php index ef4667ab8625..33a83b973384 100644 --- a/tests/integration/features/bootstrap/BasicStructure.php +++ b/tests/integration/features/bootstrap/BasicStructure.php @@ -124,6 +124,45 @@ public function getOCSResponse($response) { return $response->xml()->meta[0]->statuscode; } + /** + * Parses the xml answer to get the requested key and sub-key + * + * @param ResponseInterface $response + * @param string $key1 + * @param string $key2 + * @return string + */ + public function getXMLKey1Key2Value($response, $key1, $key2) { + return $response->xml()->$key1->$key2; + } + + /** + * Parses the xml answer to get the requested key sequence + * + * @param ResponseInterface $response + * @param string $key1 + * @param string $key2 + * @param string $key3 + * @return string + */ + public function getXMLKey1Key2Key3Value($response, $key1, $key2, $key3) { + return $response->xml()->$key1->$key2->$key3; + } + + /** + * Parses the xml answer to get the requested attribute value + * + * @param ResponseInterface $response + * @param string $key1 + * @param string $key2 + * @param string $key3 + * @param string $attribute + * @return string + */ + public function getXMLKey1Key2Key3AttributeValue($response, $key1, $key2, $key3, $attribute) { + return (string) $response->xml()->$key1->$key2->$key3->attributes()->$attribute; + } + /** * This function is needed to use a vertical fashion in the gherkin tables. * @param array $arrayOfArrays @@ -224,6 +263,49 @@ public function theHTTPStatusCodeShouldBe($statusCode) { PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode()); } + /** + * @Then /^the XML "([^"]*)" "([^"]*)" value should be "([^"]*)"$/ + * @param string $key1 + * @param string $key2 + * @param string $idText + */ + public function theXMLKey1Key2ValueShouldBe($key1, $key2, $idText) { + PHPUnit_Framework_Assert::assertEquals( + $idText, + $this->getXMLKey1Key2Value($this->response, $key1, $key2) + ); + } + + /** + * @Then /^the XML "([^"]*)" "([^"]*)" "([^"]*)" value should be "([^"]*)"$/ + * @param string $key1 + * @param string $key2 + * @param string $key3 + * @param string $idText + */ + public function theXMLKey1Key2Key3ValueShouldBe($key1, $key2, $key3, $idText) { + PHPUnit_Framework_Assert::assertEquals( + $idText, + $this->getXMLKey1Key2Key3Value($this->response, $key1, $key2, $key3) + ); + } + + /** + * @Then /^the XML "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" attribute value should be a valid version string$/ + * @param string $key1 + * @param string $key2 + * @param string $key3 + * @param string $attribute + * @param string $idText + */ + public function theXMLKey1Key2AttributeValueShouldBe($key1, $key2, $key3, $attribute) { + $value = $this->getXMLKey1Key2Key3AttributeValue($this->response, $key1, $key2, $key3, $attribute); + PHPUnit_Framework_Assert::assertTrue( + version_compare($value, '0.0.1') >= 0, + 'attribute ' . $attribute . ' value ' . $value . ' is not a valid version string' + ); + } + /** * @param ResponseInterface $response */ diff --git a/tests/integration/features/provisioning-v1.feature b/tests/integration/features/provisioning-v1.feature index ffd96b8504b2..02f5aecac52a 100644 --- a/tests/integration/features/provisioning-v1.feature +++ b/tests/integration/features/provisioning-v1.feature @@ -301,6 +301,11 @@ Feature: provisioning When sending "GET" to "/cloud/apps/files" Then the OCS status code should be "100" And the HTTP status code should be "200" + And the XML "data" "id" value should be "files" + And the XML "data" "name" value should be "Files" + And the XML "data" "types" "element" value should be "filesystem" + And the XML "data" "dependencies" "owncloud" "min-version" attribute value should be a valid version string + And the XML "data" "dependencies" "owncloud" "max-version" attribute value should be a valid version string # Scenario: enable an app # Given as an "admin"