Skip to content

Commit

Permalink
add test to check file rename activity using file-id
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Oct 18, 2024
1 parent ce8a8fa commit ca0157b
Show file tree
Hide file tree
Showing 2 changed files with 558 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,65 @@ public function userCopiesOrMovesFileWithFileIdFromAndToSpaceBetweenSpaces(strin
}
}

/**
* @Given /^user "([^"]*)" has (copied|moved|renamed) a file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id path "([^"]*)"$/
*
* @param string $user
* @param string $actionType
* @param string $sourceFile
* @param string $destinationFile
* @param string $toSpaceName
* @param string $url
*
* @return void
* @throws GuzzleException
*/
public function userHasRenamedAFileIntoUsingFileIdPath(string $user, string $actionType, string $sourceFile, string $destinationFile, string $toSpaceName, string $url): void {
$sourceFile = \trim($sourceFile, "/");
$sourceFile = \explode("/", $sourceFile);
$sourceFile = \end($sourceFile);
$destinationFile = \trim($destinationFile, "/");
$fileDestination = '';
if ($actionType === 'copied' || $actionType === 'moved') {
$fileDestination = $this->escapePath($destinationFile) . '/' . $this->escapePath($sourceFile);
} else {
$fileDestination = $destinationFile;
}
$baseUrl = $this->featureContext->getBaseUrl();
if ($toSpaceName === 'Shares') {
$sharesPath = $this->featureContext->getSharesMountPath($user, $fileDestination);
$davPath = WebDavHelper::getDavPath($user, $this->featureContext->getDavPathVersion());
$headers['Destination'] = $baseUrl . "/$davPath" . $sharesPath;
} else {
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $url);
}
$fullUrl = $baseUrl . $url;
if ($actionType === 'copied') {
$response = $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
} else {
$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
}
Assert::assertEquals(
201,
$response->getStatusCode(),
"Response did not return expected status code"
);
}

/**
* @Given user :user has sent HTTP method :verb to URL :url with content :content
*
* @param string $user
* @param string $url
* @param string $content
*
* @return void
*/
public function userHasEditedAFileWithContentInsideSpaceUsingFileIdPath(string $user, string $url, string $content): void {
$response = $this->featureContext->sendingToWithDirectUrl($user, 'PUT', $url, $content);
$this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response);
}

/**
* @When /^user "([^"]*)" tries to move (?:file|folder) "([^"]*)" of space "([^"]*)" to (space|folder) "([^"]*)" using its id in destination path "([^"]*)"$/
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" of space "([^"]*)" to (folder) "([^"]*)" using its id in destination path "([^"]*)"$/
Expand Down
Loading

0 comments on commit ca0157b

Please sign in to comment.