diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2023-11-23 00:43:19 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2023-11-23 00:43:26 -0100 |
commit | fbe92d4a9018b8439946880148c2b907ea56c56c (patch) | |
tree | 59c384351bdcd27d16837808d8e51e6f51f22395 /build/integration | |
parent | a93af13c12fc072c8b612b72c86ea3540f19e0fd (diff) | |
download | nextcloud-server-fbe92d4a9018b8439946880148c2b907ea56c56c.tar.gz nextcloud-server-fbe92d4a9018b8439946880148c2b907ea56c56c.zip |
fixing test
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'build/integration')
-rw-r--r-- | build/integration/features/bootstrap/CommentsContext.php | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/build/integration/features/bootstrap/CommentsContext.php b/build/integration/features/bootstrap/CommentsContext.php index ad2d752b4dd..989f34692ca 100644 --- a/build/integration/features/bootstrap/CommentsContext.php +++ b/build/integration/features/bootstrap/CommentsContext.php @@ -49,6 +49,37 @@ class CommentsContext implements \Behat\Behat\Context\Context { } } + + + /** + * get a named entry from response instead of picking a random entry from values + * + * @param string $path + * + * @return array|string + * @throws Exception + */ + private function getValueFromNamedEntries(string $path, array $response): mixed { + $next = ''; + if (str_contains($path, ' ')) { + [$key, $next] = explode(' ', $path, 2); + } else { + $key = $path; + } + + foreach ($response as $entry) { + if ($entry['name'] === $key) { + if ($next !== '') { + return $this->getValueFromNamedEntries($next, $entry['value']); + } else { + return $entry['value']; + } + } + } + + return null; + } + /** @AfterScenario */ public function teardownScenario() { $client = new \GuzzleHttp\Client(); @@ -175,7 +206,7 @@ class CommentsContext implements \Behat\Behat\Context\Context { if ($res->getStatusCode() === 207) { $service = new Sabre\Xml\Service(); $this->response = $service->parse($res->getBody()->getContents()); - $this->commentId = (int) ($this->response[0]['value'][2]['value'][0]['value'][0]['value'] ?? 0); + $this->commentId = (int) ($this->getValueFromNamedEntries('{DAV:}response {DAV:}propstat {DAV:}prop {http://owncloud.org/ns}id', $this->response ?? []) ?? 0); } } @@ -238,7 +269,8 @@ class CommentsContext implements \Behat\Behat\Context\Context { * @throws \Exception */ public function theResponseShouldContainAPropertyWithValue($key, $value) { - $keys = $this->response[0]['value'][2]['value'][0]['value']; +// $keys = $this->response[0]['value'][1]['value'][0]['value']; + $keys = $this->getValueFromNamedEntries('{DAV:}response {DAV:}propstat {DAV:}prop', $this->response); $found = false; foreach ($keys as $singleKey) { if ($singleKey['name'] === '{http://owncloud.org/ns}' . substr($key, 3)) { |