Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/private/legacy/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
82 changes: 82 additions & 0 deletions tests/integration/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/features/provisioning-v1.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down