From 2b1f6bc51399f1c851732ea1a4d1a428a3f758b0 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Fri, 22 Jul 2022 10:14:06 +0545 Subject: [PATCH] Move Implementation operation --- .../features/bootstrap/SpacesContext.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 4e1a1be02af..c7d341387d9 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1747,6 +1747,56 @@ public function userCopiesFileWithinSpaceUsingTheWebDAVAPI( $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers); } + /** + * @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" to "([^"]*)" in space "([^"]*)" using the WebDAV API$/ + * + * @param string $user + * @param string $fileSource + * @param string $fileDestination + * @param string $spaceName + * + * @return void + */ + public function userMovesFileWithinSpaceUsingTheWebDAVAPI( + string $user, + string $fileSource, + string $fileDestination, + string $spaceName + ):void { + $space = $this->getSpaceByName($user, $spaceName); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $spaceName + ); + + $fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/"); + $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers); + } + + /** + * MOVE request for files|folders + * + * @param string $user + * @param string $fullUrl + * @param string $headers + * + * @return void + * @throws GuzzleException + */ + public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array $headers):void { + $this->featureContext->setResponse( + HttpRequestHelper::sendRequest( + $fullUrl, + $this->featureContext->getStepLineRef(), + 'MOVE', + $user, + $this->featureContext->getPasswordForUser($user), + $headers, + ) + ); + } + /** * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/ * @@ -1772,6 +1822,32 @@ public function userCopiesFileFromAndToSpaceBetweenSpaces( $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers); } + + /** + * @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/ + * + * @param string $user + * @param string $fileSource + * @param string $fromSpaceName + * @param string $fileDestination + * @param string $toSpaceName + * + * @return void + * @throws GuzzleException + */ + public function userMovesFileFromAndToSpaceBetweenSpaces( + string $user, + string $fileSource, + string $fromSpaceName, + string $fileDestination, + string $toSpaceName + ):void { + $space = $this->getSpaceByName($user, $fromSpaceName); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); + $fullUrl = $space["root"]["webDavUrl"] . '/' . \ltrim($fileSource, "/"); + $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers); + } + /** * returns a url for destination with spacename *