Skip to content

Commit

Permalink
Merge pull request #10409 from owncloud/tests-move-activities-by-fileid
Browse files Browse the repository at this point in the history
[tests-only][full-ci] add test to check activities of destination file and folder by moving a file using file-id
  • Loading branch information
saw-jan authored Nov 14, 2024
2 parents 8380f21 + 8b9da7b commit 61ce572
Show file tree
Hide file tree
Showing 2 changed files with 867 additions and 19 deletions.
64 changes: 49 additions & 15 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2040,36 +2040,30 @@ public function userCopiesMovesFileIntoInsideSpaceUsingFileId(string $user, stri
}

/**
* @Given /^user "([^"]*)" has (copied|moved|renamed) file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id "([^"]*)"$/
* @Given /^user "([^"]*)" has (copied|moved) file with id "([^"]*)" as "([^"]*)" into folder "([^"]*)" inside space "([^"]*)"$/
*
* @param string $user
* @param string $actionType
* @param string $sourceFile
* @param string $fileId
* @param string $destinationFile
* @param string $destinationFolder
* @param string $spaceName
* @param string $fileId
*
* @throws GuzzleException
* @return void
*/
public function userHasCopiedOrMovedFileInsideSpaceUsingFileId(
string $user,
string $actionType,
string $sourceFile,
string $fileId,
string $destinationFile,
string $destinationFolder,
string $spaceName,
string $fileId
): void {
// split the source when there are sub-folders
$sourceFile = \trim($sourceFile, "/");
$sourceFile = \explode("/", $sourceFile);
$sourceFile = \end($sourceFile);
$destinationFile = \trim($destinationFile, "/");
if ($actionType === 'copied' || $actionType === 'moved') {
$fileDestination = $this->escapePath($destinationFile) . '/' . $this->escapePath($sourceFile);
} else {
$fileDestination = $destinationFile;
}
$destinationFolder = \trim($destinationFolder, "/");

$fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile);

$baseUrl = $this->featureContext->getBaseUrl();
$sourceDavPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
Expand All @@ -2093,6 +2087,45 @@ public function userHasCopiedOrMovedFileInsideSpaceUsingFileId(
);
}

/**
* @Given /^user "([^"]*)" has renamed file with id "([^"]*)" to "([^"]*)" inside space "([^"]*)"$/
*
* @param string $user
* @param string $fileId
* @param string $destinationFile
* @param string $spaceName
*
* @throws GuzzleException
* @return void
*/
public function userHasRenamedFileInsideSpaceUsingFileId(
string $user,
string $fileId,
string $destinationFile,
string $spaceName
): void {
$destinationFile = \trim($destinationFile, "/");

$fileDestination = $this->escapePath($destinationFile);

$baseUrl = $this->featureContext->getBaseUrl();
$sourceDavPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
if ($spaceName === 'Shares') {
$sharesPath = $this->featureContext->getSharesMountPath($user, $fileDestination);
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
} else {
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId);
}
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
Assert::assertEquals(
201,
$response->getStatusCode(),
"Expected response status code should be 201"
);
}

/**
* @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 Expand Up @@ -3656,14 +3689,15 @@ public function userHasStoredIdOfPathOfTheSpace(string $user, string $path, stri
/**
* @Then /^user "([^"]*)" (folder|file) "([^"]*)" of the space "([^"]*)" should have the previously stored id$/
*
* @param string|null $user
* @param string $user
* @param string $fileOrFolder
* @param string $path
* @param string $spaceName
*
* @return void
*
* @throws GuzzleException
* @throws JsonException
*/
public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user, string $fileOrFolder, string $path, string $spaceName): void {
$this->getSpaceIdByName($user, $spaceName);
Expand Down
Loading

0 comments on commit 61ce572

Please sign in to comment.