mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 21:00:30 -06:00
removing usage of a stepdefination inside another stepdefination in TrashbinContext (#8755)
This commit is contained in:
@@ -512,7 +512,10 @@ class TrashbinContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userTriesToDeleteFromTrashbinOfUser(string $asUser, string $path, string $user):void {
|
||||
$numItemsDeleted = $this->tryToDeleteFileFromTrashbin($user, $path, $asUser);
|
||||
$responseArray = $this->tryToDeleteFileFromTrashbin($user, $path, $asUser);
|
||||
foreach ($responseArray as $response) {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,7 +533,10 @@ class TrashbinContext implements Context {
|
||||
public function userTriesToDeleteFromTrashbinOfUserUsingPassword(?string $asUser, ?string $path, ?string $user, ?string $password):void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$asUser = $this->featureContext->getActualUsername($asUser);
|
||||
$this->tryToDeleteFileFromTrashbin($user, $path, $asUser, $password);
|
||||
$responseArray = $this->tryToDeleteFileFromTrashbin($user, $path, $asUser, $password);
|
||||
foreach ($responseArray as $response) {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -589,21 +595,33 @@ class TrashbinContext implements Context {
|
||||
/**
|
||||
* @When /^user "([^"]*)" tries to delete the (?:file|folder|entry) with original path "([^"]*)" from the trashbin using the trashbin API$/
|
||||
*
|
||||
* @param string|null $user
|
||||
* @param string|null $originalPath
|
||||
* @param string|null $asUser
|
||||
* @param string|null $password
|
||||
* @param string $user
|
||||
* @param string $originalPath
|
||||
*
|
||||
* @return int the number of items that were matched and requested for delete
|
||||
* @throws JsonException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function tryToDeleteFileFromTrashbin(?string $user, ?string $originalPath, ?string $asUser = null, ?string $password = null):int {
|
||||
public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(string $user, string $originalPath):void {
|
||||
$responseArray = $this->tryToDeleteFileFromTrashbin($user, $originalPath);
|
||||
foreach ($responseArray as $response) {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $user
|
||||
* @param string|null $originalPath
|
||||
* @param string|null $asUser
|
||||
* @param string|null $password
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tryToDeleteFileFromTrashbin(?string $user, ?string $originalPath, ?string $asUser = null, ?string $password = null):array {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$asUser = $asUser ?? $user;
|
||||
$listing = $this->listTrashbinFolder($user);
|
||||
$originalPath = \trim($originalPath, '/');
|
||||
$numItemsDeleted = 0;
|
||||
|
||||
foreach ($listing as $entry) {
|
||||
// The entry for the trashbin root can have original-location null.
|
||||
@@ -624,12 +642,11 @@ class TrashbinContext implements Context {
|
||||
[],
|
||||
$user
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
$numItemsDeleted++;
|
||||
$responseArray[] = $response;
|
||||
}
|
||||
}
|
||||
|
||||
return $numItemsDeleted;
|
||||
return $responseArray;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -642,13 +659,16 @@ class TrashbinContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteFileFromTrashbin(string $user, string $originalPath):void {
|
||||
$numItemsDeleted = $this->tryToDeleteFileFromTrashbin($user, $originalPath);
|
||||
|
||||
$responseArray = $this->tryToDeleteFileFromTrashbin($user, $originalPath);
|
||||
$numItemDeleted = \count($responseArray);
|
||||
Assert::assertEquals(
|
||||
1,
|
||||
$numItemsDeleted,
|
||||
"Expected to delete exactly one item from the trashbin but $numItemsDeleted were deleted"
|
||||
$numItemDeleted,
|
||||
"Expected to delete exactly one item from the trashbin but $numItemDeleted were deleted"
|
||||
);
|
||||
foreach ($responseArray as $response) {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
$this->featureContext->pushToLastStatusCodesArrays();
|
||||
}
|
||||
|
||||
@@ -666,8 +686,17 @@ class TrashbinContext implements Context {
|
||||
$paths = $table->getHash();
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$this->deleteFileFromTrashbin($user, $path["path"]);
|
||||
$responseArray = $this->tryToDeleteFileFromTrashbin($user, $path["path"]);
|
||||
$numItemsDeleted = \count($responseArray);
|
||||
|
||||
Assert::assertEquals(
|
||||
1,
|
||||
$numItemsDeleted,
|
||||
"Expected to delete exactly one item from the trashbin but $numItemsDeleted were deleted"
|
||||
);
|
||||
foreach ($responseArray as $response) {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
$this->featureContext->pushToLastStatusCodesArrays();
|
||||
}
|
||||
}
|
||||
@@ -940,8 +969,8 @@ class TrashbinContext implements Context {
|
||||
$paths = $table->getHash();
|
||||
|
||||
foreach ($paths as $originalPath) {
|
||||
$this->elementInTrashIsRestored($user, $originalPath["path"]);
|
||||
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$this->featureContext->setResponse($this->restoreElement($user, $originalPath["path"]));
|
||||
$this->featureContext->pushToLastStatusCodesArrays();
|
||||
}
|
||||
}
|
||||
@@ -1041,7 +1070,11 @@ class TrashbinContext implements Context {
|
||||
$paths = $table->getHash();
|
||||
|
||||
foreach ($paths as $originalPath) {
|
||||
$this->elementIsNotInTrashCheckingOriginalPath($user, $originalPath["path"]);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
Assert::assertFalse(
|
||||
$this->isInTrash($user, $originalPath["path"]),
|
||||
"File previously located at " . $originalPath["path"] . " was found in the trashbin of user $user"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1062,7 +1095,11 @@ class TrashbinContext implements Context {
|
||||
$paths = $table->getHash();
|
||||
|
||||
foreach ($paths as $originalPath) {
|
||||
$this->elementIsInTrashCheckingOriginalPath($user, $originalPath["path"]);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
Assert::assertTrue(
|
||||
$this->isInTrash($user, $originalPath["path"]),
|
||||
"File previously located at " . $originalPath["path"] . " wasn't found in the trashbin of user $user"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user