diff options
Diffstat (limited to 'build/integration/features/bootstrap/WebDav.php')
-rw-r--r-- | build/integration/features/bootstrap/WebDav.php | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 567f189c61e..8f0f30b377a 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -21,7 +21,7 @@ trait WebDav{ $this->davPath = $davPath; } - public function makeDavRequest($user, $method, $path, $headers){ + public function makeDavRequest($user, $method, $path, $headers, $body = null){ $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path"; $client = new GClient(); $options = []; @@ -36,6 +36,11 @@ trait WebDav{ $request->addHeader($key, $value); } } + + if (!is_null($body)) { + $request->setBody($body); + } + return $client->send($request); } @@ -115,7 +120,20 @@ trait WebDav{ } } } - + + /** + * @When User :user uploads file :source to :destination + */ + public function userUploadsAFileTo($user, $source, $destination) + { + $file = \GuzzleHttp\Stream\Stream::factory(fopen($source, 'r')); + try { + $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file); + } catch (\GuzzleHttp\Exception\ServerException $e) { + // 4xx and 5xx responses cause an exception + $this->response = $e->getResponse(); + } + } } |