diff options
Diffstat (limited to 'build/integration/features/bootstrap/WebDav.php')
-rw-r--r-- | build/integration/features/bootstrap/WebDav.php | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 71f938c7ec4..262955e4e5c 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -260,6 +260,32 @@ trait WebDav { } /** + * @Then /^as "([^"]*)" the (file|folder|entry) "([^"]*)" does not exist$/ + * @param string $user + * @param string $path + * @param \Behat\Gherkin\Node\TableNode|null $propertiesTable + */ + public function asTheFileOrFolderDoesNotExist($user, $entry, $path) { + $client = $this->getSabreClient($user); + $response = $client->request('HEAD', $this->makeSabrePath($path)); + if ($response['statusCode'] !== 404) { + throw new \Exception($entry . ' "' . $path . '" expected to not exist (status code ' . $response['statusCode'] . ', expected 404)'); + } + + return $response; + } + + /** + * @Then /^as "([^"]*)" the (file|folder|entry) "([^"]*)" exists$/ + * @param string $user + * @param string $path + * @param \Behat\Gherkin\Node\TableNode|null $propertiesTable + */ + public function asTheFileOrFolderExists($user, $entry, $path) { + $this->response = $this->listFolder($user, $path, 0); + } + + /** * @Then the single response should contain a property :key with value :value * @param string $key * @param string $expectedValue @@ -327,9 +353,25 @@ trait WebDav { } } - /*Returns the elements of a propfind, $folderDepth requires 1 to see elements without children*/ public function listFolder($user, $path, $folderDepth, $properties = null){ + $client = $this->getSabreClient($user); + if (!$properties) { + $properties = [ + '{DAV:}getetag' + ]; + } + + $response = $client->propfind($this->makeSabrePath($path), $properties, $folderDepth); + + return $response; + } + + public function makeSabrePath($path) { + return $this->encodePath($this->davPath . '/' . ltrim($path, '/')); + } + + public function getSabreClient($user) { $fullUrl = substr($this->baseUrl, 0, -4); $settings = array( @@ -343,17 +385,7 @@ trait WebDav { $settings['password'] = $this->regularUser; } - $client = new SClient($settings); - - if (!$properties) { - $properties = [ - '{DAV:}getetag' - ]; - } - - $response = $client->propfind($this->davPath . '/' . ltrim($path, '/'), $properties, $folderDepth); - - return $response; + return new SClient($settings); } /** @@ -494,6 +526,17 @@ trait WebDav { } /** + * URL encodes the given path but keeps the slashes + * + * @param string $path to encode + * @return string encoded path + */ + private function encodePath($path) { + // slashes need to stay + return str_replace('%2F', '/', rawurlencode($path)); + } + + /** * @When user :user favorites element :path */ public function userFavoritesElement($user, $path){ |