Skip to content

Commit

Permalink
Move Implementation operation
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarGi authored and SwikritiT committed Jul 26, 2022
1 parent 771d6d6 commit 2b1f6bc
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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$/
*
Expand All @@ -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
*
Expand Down

0 comments on commit 2b1f6bc

Please sign in to comment.