delete unnecessary steps from context files

This commit is contained in:
Viktor Scharf
2025-02-05 19:43:12 +01:00
parent 46df1a041e
commit 72fd765b93
14 changed files with 295 additions and 1586 deletions
@@ -23,7 +23,6 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode; use Behat\Gherkin\Node\TableNode;
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
use TestHelpers\HttpRequestHelper; use TestHelpers\HttpRequestHelper;
use TestHelpers\SetupHelper;
use TestHelpers\BehatHelper; use TestHelpers\BehatHelper;
use PHPUnit\Framework\Assert; use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@@ -932,26 +932,6 @@ class FeatureContext extends BehatVariablesContext {
$this->ocsApiVersion = (int)$version; $this->ocsApiVersion = (int)$version;
} }
/**
* @Given /^as user "([^"]*)"$/
*
* @param string $user
*
* @return void
*/
public function asUser(string $user): void {
$this->currentUser = $this->getActualUsername($user);
}
/**
* @Given as the administrator
*
* @return void
*/
public function asTheAdministrator(): void {
$this->currentUser = $this->getAdminUsername();
}
/** /**
* @return string * @return string
*/ */
@@ -1690,21 +1670,6 @@ class FeatureContext extends BehatVariablesContext {
); );
} }
/**
* @Then the HTTP status code should be failure
*
* @return void
*/
public function theHTTPStatusCodeShouldBeFailure(): void {
$statusCode = $this->response->getStatusCode();
$message = "The HTTP status code $statusCode is not greater than or equals to 400";
Assert::assertGreaterThanOrEqual(
400,
$statusCode,
$message
);
}
/** /**
* @param string $path * @param string $path
* @param string $filename * @param string $filename
@@ -170,20 +170,6 @@ class FilesVersionsContext implements Context {
); );
} }
/**
* @When user :user gets the version metadata of file :file
*
* @param string $user
* @param string $file
*
* @return void
* @throws Exception
*/
public function userGetsVersionMetadataOfFile(string $user, string $file): void {
$response = $this->getFileVersionMetadata($user, $file);
$this->featureContext->setResponse($response, $user);
}
/** /**
* @param string $user * @param string $user
* @param string $file * @param string $file
@@ -335,24 +321,6 @@ class FilesVersionsContext implements Context {
$this->assertFileVersionsCount($user, $fileId, $count); $this->assertFileVersionsCount($user, $fileId, $count);
} }
/**
* @Then the version folder of fileId :fileId for user :user should contain :count element(s)
*
* @param string $fileId
* @param string $user
* @param int $count
*
* @return void
* @throws Exception
*/
public function theVersionFolderOfFileIdShouldContainElements(
string $fileId,
string $user,
int $count
): void {
$this->assertFileVersionsCount($user, $fileId, $count);
}
/** /**
* @Then the content length of file :path with version index :index for user :user in versions folder should be :length * @Then the content length of file :path with version index :index for user :user in versions folder should be :length
* *
@@ -25,7 +25,6 @@ require_once 'bootstrap.php';
class NotificationContext implements Context { class NotificationContext implements Context {
private FeatureContext $featureContext; private FeatureContext $featureContext;
private SpacesContext $spacesContext; private SpacesContext $spacesContext;
private SettingsContext $settingsContext;
private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications?format=json'; private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications?format=json';
private string $globalNotificationEndpointPath = '/apps/notifications/api/v1/notifications/global'; private string $globalNotificationEndpointPath = '/apps/notifications/api/v1/notifications/global';
@@ -99,7 +98,6 @@ class NotificationContext implements Context {
// Get all the contexts you need in this context // Get all the contexts you need in this context
$this->featureContext = BehatHelper::getContext($scope, $environment, 'FeatureContext'); $this->featureContext = BehatHelper::getContext($scope, $environment, 'FeatureContext');
$this->spacesContext = BehatHelper::getContext($scope, $environment, 'SpacesContext'); $this->spacesContext = BehatHelper::getContext($scope, $environment, 'SpacesContext');
$this->settingsContext = BehatHelper::getContext($scope, $environment, 'SettingsContext');
} }
/** /**
+289 -289
View File
@@ -37,40 +37,40 @@ require_once 'bootstrap.php';
class OCSContext implements Context { class OCSContext implements Context {
private FeatureContext $featureContext; private FeatureContext $featureContext;
/** // /**
* @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/ // * @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* // *
* @return void // * @return void
*/ // */
public function theUserSendsToOcsApiEndpoint(string $verb, string $url): void { // public function theUserSendsToOcsApiEndpoint(string $verb, string $url): void {
$response = $this->theUserSendsToOcsApiEndpointWithBody($verb, $url); // $response = $this->theUserSendsToOcsApiEndpointWithBody($verb, $url);
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** // /**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/ // * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)"$/
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" using password "([^"]*)"$/ // * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" using password "([^"]*)"$/
* // *
* @param string $user // * @param string $user
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param string|null $password // * @param string|null $password
* // *
* @return void // * @return void
*/ // */
public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null): void { // public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null): void {
$response = $this->sendRequestToOcsEndpoint( // $response = $this->sendRequestToOcsEndpoint(
$user, // $user,
$verb, // $verb,
$url, // $url,
null, // null,
$password // $password
); // );
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** /**
* @param string $user * @param string $user
@@ -162,59 +162,59 @@ class OCSContext implements Context {
); );
} }
/** // /**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/ // * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/
* // *
* @param string $user // * @param string $user
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param TableNode|null $body // * @param TableNode|null $body
* @param string|null $password // * @param string|null $password
* // *
* @return void // * @return void
*/ // */
public function userSendHTTPMethodToOcsApiEndpointWithBody( // public function userSendHTTPMethodToOcsApiEndpointWithBody(
string $user, // string $user,
string $verb, // string $verb,
string $url, // string $url,
?TableNode $body = null, // ?TableNode $body = null,
?string $password = null // ?string $password = null
): void { // ): void {
$response = $this->sendRequestToOcsEndpoint( // $response = $this->sendRequestToOcsEndpoint(
$user, // $user,
$verb, // $verb,
$url, // $url,
$body, // $body,
$password // $password
); // );
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** // /**
* @When the administrator sends HTTP method :verb to OCS API endpoint :url // * @When the administrator sends HTTP method :verb to OCS API endpoint :url
* @When the administrator sends HTTP method :verb to OCS API endpoint :url using password :password // * @When the administrator sends HTTP method :verb to OCS API endpoint :url using password :password
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param string|null $password // * @param string|null $password
* // *
* @return void // * @return void
*/ // */
public function theAdministratorSendsHttpMethodToOcsApiEndpoint( // public function theAdministratorSendsHttpMethodToOcsApiEndpoint(
string $verb, // string $verb,
string $url, // string $url,
?string $password = null // ?string $password = null
): void { // ): void {
$this->featureContext->setResponse( // $this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint( // $this->sendRequestToOcsEndpoint(
$this->featureContext->getAdminUsername(), // $this->featureContext->getAdminUsername(),
$verb, // $verb,
$url, // $url,
null, // null,
$password // $password
) // )
); // );
} // }
/** /**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/ * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/
@@ -247,158 +247,158 @@ class OCSContext implements Context {
); );
} }
/** // /**
* @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/ // * @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers$/
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param TableNode $headersTable // * @param TableNode $headersTable
* // *
* @return void // * @return void
* @throws Exception // * @throws Exception
*/ // */
public function administratorSendsToOcsApiEndpointWithHeaders( // public function administratorSendsToOcsApiEndpointWithHeaders(
string $verb, // string $verb,
string $url, // string $url,
TableNode $headersTable // TableNode $headersTable
): void { // ): void {
$user = $this->featureContext->getAdminUsername(); // $user = $this->featureContext->getAdminUsername();
$password = $this->featureContext->getPasswordForUser($user); // $password = $this->featureContext->getPasswordForUser($user);
$this->featureContext->setResponse( // $this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint( // $this->sendRequestToOcsEndpoint(
$user, // $user,
$verb, // $verb,
$url, // $url,
null, // null,
$password, // $password,
$headersTable->getRowsHash() // $headersTable->getRowsHash()
) // )
); // );
} // }
/** // /**
* @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers using password "([^"]*)"$/ // * @When /^the administrator sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with headers using password "([^"]*)"$/
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param string $password // * @param string $password
* @param TableNode $headersTable // * @param TableNode $headersTable
* // *
* @return void // * @return void
* @throws Exception // * @throws Exception
*/ // */
public function administratorSendsToOcsApiEndpointWithHeadersAndPassword( // public function administratorSendsToOcsApiEndpointWithHeadersAndPassword(
string $verb, // string $verb,
string $url, // string $url,
string $password, // string $password,
TableNode $headersTable // TableNode $headersTable
): void { // ): void {
$this->featureContext->setResponse( // $this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint( // $this->sendRequestToOcsEndpoint(
$this->featureContext->getAdminUsername(), // $this->featureContext->getAdminUsername(),
$verb, // $verb,
$url, // $url,
null, // null,
$password, // $password,
$headersTable->getRowsHash() // $headersTable->getRowsHash()
) // )
); // );
} // }
/** // /**
* @When the administrator sends HTTP method :verb to OCS API endpoint :url with body // * @When the administrator sends HTTP method :verb to OCS API endpoint :url with body
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param TableNode|null $body // * @param TableNode|null $body
* // *
* @return void // * @return void
*/ // */
public function theAdministratorSendsHttpMethodToOcsApiEndpointWithBody( // public function theAdministratorSendsHttpMethodToOcsApiEndpointWithBody(
string $verb, // string $verb,
string $url, // string $url,
?TableNode $body // ?TableNode $body
): void { // ): void {
$response = $this->adminSendsHttpMethodToOcsApiEndpointWithBody( // $response = $this->adminSendsHttpMethodToOcsApiEndpointWithBody(
$verb, // $verb,
$url, // $url,
$body // $body
); // );
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** // /**
* @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/ // * @When /^the user sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body$/
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param TableNode $body // * @param TableNode $body
* // *
* @return void // * @return void
*/ // */
public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body): void { // public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body): void {
$response = $this->theUserSendsToOcsApiEndpointWithBody( // $response = $this->theUserSendsToOcsApiEndpointWithBody(
$verb, // $verb,
$url, // $url,
$body // $body
); // );
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** // /**
* @When the administrator sends HTTP method :verb to OCS API endpoint :url with body using password :password // * @When the administrator sends HTTP method :verb to OCS API endpoint :url with body using password :password
* // *
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param string $password // * @param string $password
* @param TableNode $body // * @param TableNode $body
* // *
* @return void // * @return void
*/ // */
public function theAdministratorSendsHttpMethodToOcsApiWithBodyAndPassword( // public function theAdministratorSendsHttpMethodToOcsApiWithBodyAndPassword(
string $verb, // string $verb,
string $url, // string $url,
string $password, // string $password,
TableNode $body // TableNode $body
): void { // ): void {
$admin = $this->featureContext->getAdminUsername(); // $admin = $this->featureContext->getAdminUsername();
$response = $this->sendRequestToOcsEndpoint( // $response = $this->sendRequestToOcsEndpoint(
$admin, // $admin,
$verb, // $verb,
$url, // $url,
$body, // $body,
$password // $password
); // );
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** // /**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body using password "([^"]*)"$/ // * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body using password "([^"]*)"$/
* // *
* @param string $user // * @param string $user
* @param string $verb // * @param string $verb
* @param string $url // * @param string $url
* @param string $password // * @param string $password
* @param TableNode $body // * @param TableNode $body
* // *
* @return void // * @return void
*/ // */
public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword( // public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword(
string $user, // string $user,
string $verb, // string $verb,
string $url, // string $url,
string $password, // string $password,
TableNode $body // TableNode $body
): void { // ): void {
$response = $this->sendRequestToOcsEndpoint( // $response = $this->sendRequestToOcsEndpoint(
$user, // $user,
$verb, // $verb,
$url, // $url,
$body, // $body,
$password // $password
); // );
$this->featureContext->setResponse($response); // $this->featureContext->setResponse($response);
} // }
/** /**
* @Then /^the OCS status code should be "([^"]*)"$/ * @Then /^the OCS status code should be "([^"]*)"$/
@@ -494,64 +494,64 @@ class OCSContext implements Context {
); );
} }
/** // /**
* Check the text in an OCS status message // * Check the text in an OCS status message
* // *
* @Then /^the OCS status message about user "([^"]*)" should be "([^"]*)"$/ // * @Then /^the OCS status message about user "([^"]*)" should be "([^"]*)"$/
* // *
* @param string $user // * @param string $user
* @param string $statusMessage // * @param string $statusMessage
* // *
* @return void // * @return void
*/ // */
public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage): void { // public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage): void {
$user = \strtolower($this->featureContext->getActualUsername($user)); // $user = \strtolower($this->featureContext->getActualUsername($user));
$statusMessage = $this->featureContext->substituteInLineCodes( // $statusMessage = $this->featureContext->substituteInLineCodes(
$statusMessage, // $statusMessage,
$user // $user
); // );
Assert::assertEquals( // Assert::assertEquals(
$statusMessage, // $statusMessage,
$this->getOCSResponseStatusMessage( // $this->getOCSResponseStatusMessage(
$this->featureContext->getResponse() // $this->featureContext->getResponse()
), // ),
'Unexpected OCS status message :"' . $this->getOCSResponseStatusMessage( // 'Unexpected OCS status message :"' . $this->getOCSResponseStatusMessage(
$this->featureContext->getResponse() // $this->featureContext->getResponse()
) . '" in response' // ) . '" in response'
); // );
} // }
/** // /**
* Check the text in an OCS status message. // * Check the text in an OCS status message.
* Use this step form if the expected text contains double quotes, // * Use this step form if the expected text contains double quotes,
* single quotes and other content that theOCSStatusMessageShouldBe() // * single quotes and other content that theOCSStatusMessageShouldBe()
* cannot handle. // * cannot handle.
* // *
* After the step, write the expected text in PyString form like: // * After the step, write the expected text in PyString form like:
* // *
* """ // * """
* File "abc.txt" can't be shared due to reason "xyz" // * File "abc.txt" can't be shared due to reason "xyz"
* """ // * """
* // *
* @Then /^the OCS status message should be:$/ // * @Then /^the OCS status message should be:$/
* // *
* @param PyStringNode $statusMessage // * @param PyStringNode $statusMessage
* // *
* @return void // * @return void
*/ // */
public function theOCSStatusMessageShouldBePyString( // public function theOCSStatusMessageShouldBePyString(
PyStringNode $statusMessage // PyStringNode $statusMessage
): void { // ): void {
Assert::assertEquals( // Assert::assertEquals(
$statusMessage->getRaw(), // $statusMessage->getRaw(),
$this->getOCSResponseStatusMessage( // $this->getOCSResponseStatusMessage(
$this->featureContext->getResponse() // $this->featureContext->getResponse()
), // ),
'Unexpected OCS status message: "' . $this->getOCSResponseStatusMessage( // 'Unexpected OCS status message: "' . $this->getOCSResponseStatusMessage(
$this->featureContext->getResponse() // $this->featureContext->getResponse()
) . '" in response' // ) . '" in response'
); // );
} // }
/** /**
* Parses the xml answer to get ocs response which doesn't match with * Parses the xml answer to get ocs response which doesn't match with
@@ -132,10 +132,7 @@ class PublicWebDavContext implements Context {
); );
$password = $this->featureContext->getActualPassword($password); $password = $this->featureContext->getActualPassword($password);
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileName"; $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileName";
$userName = $this->getUsernameForPublicWebdavApi( $userName = $this->getUsernameForPublicWebdavApi($password);
$token,
$password
);
$headers = [ $headers = [
'X-Requested-With' => 'XMLHttpRequest' 'X-Requested-With' => 'XMLHttpRequest'
]; ];
@@ -205,10 +202,7 @@ class PublicWebDavContext implements Context {
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileName"; $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileName";
$password = $this->featureContext->getActualPassword($password); $password = $this->featureContext->getActualPassword($password);
$destination = $this->featureContext->getBaseUrl() . "/$davPath/$toFileName"; $destination = $this->featureContext->getBaseUrl() . "/$davPath/$toFileName";
$userName = $this->getUsernameForPublicWebdavApi( $userName = $this->getUsernameForPublicWebdavApi($password);
$token,
$password
);
$headers = [ $headers = [
'X-Requested-With' => 'XMLHttpRequest', 'X-Requested-With' => 'XMLHttpRequest',
'Destination' => $destination 'Destination' => $destination
@@ -321,10 +315,7 @@ class PublicWebDavContext implements Context {
"public-files" "public-files"
); );
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$path"; $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$path";
$userName = $this->getUsernameForPublicWebdavApi( $userName = $this->getUsernameForPublicWebdavApi($password);
$token,
$password
);
$headers = [ $headers = [
'X-Requested-With' => 'XMLHttpRequest' 'X-Requested-With' => 'XMLHttpRequest'
@@ -410,48 +401,6 @@ class PublicWebDavContext implements Context {
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
/**
* This only works with the old API, auto-rename is not supported in the new API
* auto renaming is handled on files drop folders implicitly
*
* @param string $filename target file name
* @param string $body content to upload
*
* @return ResponseInterface
*/
public function publiclyUploadingContentAutoRename(string $filename, string $body = 'test'): ResponseInterface {
return $this->publicUploadContent($filename, '', $body, true);
}
/**
* @When the public uploads file :filename with content :body with auto-rename mode using the old public WebDAV API
*
* @param string $filename target file name
* @param string $body content to upload
*
* @return void
*/
public function thePublicUploadsFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'): void {
$response = $this->publiclyUploadingContentAutoRename($filename, $body);
$this->featureContext->setResponse($response);
}
/**
* @Given the public has uploaded file :filename with content :body with auto-rename mode
*
* @param string $filename target file name
* @param string $body content to upload
*
* @return void
*/
public function thePublicHasUploadedFileWithContentWithAutoRenameMode(
string $filename,
string $body = 'test'
): void {
$response = $this->publiclyUploadingContentAutoRename($filename, $body);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
}
/** /**
* @param string $filename target file name * @param string $filename target file name
* @param string $password * @param string $password
@@ -997,10 +946,7 @@ class PublicWebDavContext implements Context {
); );
$url = $this->featureContext->getBaseUrl() . "/$davPath/"; $url = $this->featureContext->getBaseUrl() . "/$davPath/";
$password = $this->featureContext->getActualPassword($password); $password = $this->featureContext->getActualPassword($password);
$userName = $this->getUsernameForPublicWebdavApi( $userName = $this->getUsernameForPublicWebdavApi($password);
$token,
$password
);
$foldername = \implode( $foldername = \implode(
'/', '/',
\array_map('rawurlencode', \explode('/', $destination)) \array_map('rawurlencode', \explode('/', $destination))
@@ -1152,10 +1098,7 @@ class PublicWebDavContext implements Context {
$token, $token,
"public-files" "public-files"
); );
$userName = $this->getUsernameForPublicWebdavApi( $userName = $this->getUsernameForPublicWebdavApi($password);
$token,
$password
);
$filename = \implode( $filename = \implode(
'/', '/',
@@ -1184,13 +1127,11 @@ class PublicWebDavContext implements Context {
} }
/** /**
* @param string $token
* @param string $password * @param string $password
* *
* @return string|null * @return string|null
*/ */
private function getUsernameForPublicWebdavApi( private function getUsernameForPublicWebdavApi(
string $token,
string $password string $password
): ?string { ): ?string {
if ($password !== '') { if ($password !== '') {
@@ -1249,10 +1190,7 @@ class PublicWebDavContext implements Context {
"public-files" "public-files"
); );
$password = $this->featureContext->getActualPassword($password); $password = $this->featureContext->getActualPassword($password);
$username = $this->getUsernameForPublicWebdavApi( $username = $this->getUsernameForPublicWebdavApi($password);
$token,
$password
);
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath"; $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath";
$response = HttpRequestHelper::sendRequest( $response = HttpRequestHelper::sendRequest(
$fullUrl, $fullUrl,
@@ -24,7 +24,6 @@ require_once 'bootstrap.php';
*/ */
class SettingsContext implements Context { class SettingsContext implements Context {
private FeatureContext $featureContext; private FeatureContext $featureContext;
private string $settingsUrl = '/api/v0/settings/';
/** /**
* This will run before EVERY scenario. * This will run before EVERY scenario.
@@ -37,21 +37,6 @@ class ShareesContext implements Context {
private FeatureContext $featureContext; private FeatureContext $featureContext;
private OCSContext $ocsContext; private OCSContext $ocsContext;
/**
* @When /^the user gets the sharees using the sharing API with parameters$/
*
* @param TableNode $body
*
* @return void
*/
public function theUserGetsTheShareesWithParameters(TableNode $body): void {
$this->featureContext->setResponse(
$this->getShareesWithParameters(
$this->featureContext->getCurrentUser(),
$body
)
);
}
/** /**
* @When /^user "([^"]*)" gets the sharees using the sharing API with parameters$/ * @When /^user "([^"]*)" gets the sharees using the sharing API with parameters$/
File diff suppressed because it is too large Load Diff
@@ -26,7 +26,6 @@ use GuzzleHttp\Exception\GuzzleException;
use PHPUnit\Framework\Assert; use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use TestHelpers\GraphHelper; use TestHelpers\GraphHelper;
use TestHelpers\OcHelper;
use TestHelpers\WebDavHelper; use TestHelpers\WebDavHelper;
use TestHelpers\HttpRequestHelper; use TestHelpers\HttpRequestHelper;
use TestHelpers\BehatHelper; use TestHelpers\BehatHelper;
@@ -29,7 +29,6 @@ use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use TestHelpers\HttpRequestHelper; use TestHelpers\HttpRequestHelper;
use TestHelpers\WebDavHelper; use TestHelpers\WebDavHelper;
use TestHelpers\SetupHelper;
use TestHelpers\GraphHelper; use TestHelpers\GraphHelper;
use TestHelpers\OcHelper; use TestHelpers\OcHelper;
use TestHelpers\BehatHelper; use TestHelpers\BehatHelper;
@@ -14,8 +14,6 @@ use GuzzleHttp\Exception\GuzzleException;
use PHPUnit\Framework\Assert; use PHPUnit\Framework\Assert;
use TestHelpers\WebDavHelper; use TestHelpers\WebDavHelper;
use TestHelpers\BehatHelper; use TestHelpers\BehatHelper;
use TestHelpers\GraphHelper;
use TestHelpers\HttpRequestHelper;
require_once 'bootstrap.php'; require_once 'bootstrap.php';
@@ -70,17 +70,6 @@ class TrashbinContext implements Context {
public function userEmptiesTrashbin(string $user): void { public function userEmptiesTrashbin(string $user): void {
$this->featureContext->setResponse($this->emptyTrashbin($user)); $this->featureContext->setResponse($this->emptyTrashbin($user));
} }
/**
* @Given user :user has emptied the trashbin
*
* @param string $user user
*
* @return void
*/
public function userHasEmptiedTrashbin(string $user): void {
$response = $this->emptyTrashbin($user);
$this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response);
}
/** /**
* Get files list from the response from trashbin api * Get files list from the response from trashbin api
@@ -473,29 +462,6 @@ class TrashbinContext implements Context {
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
/**
* @Then the last webdav response should contain the following elements
*
* @param TableNode $elements
*
* @return void
*/
public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements): void {
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($response, __METHOD__));
$elementRows = $elements->getHash();
foreach ($elementRows as $expectedElement) {
$found = false;
$expectedPath = $expectedElement['path'];
foreach ($files as $file) {
if (\ltrim($expectedPath, "/") === \ltrim($file['original-location'], "/")) {
$found = true;
break;
}
}
Assert::assertTrue($found, "$expectedPath expected to be listed in response but not found");
}
}
/** /**
* @Then the last webdav response should not contain the following elements * @Then the last webdav response should not contain the following elements
* *
@@ -950,37 +916,6 @@ class TrashbinContext implements Context {
} }
} }
/**
* @Then /^the content of file "([^"]*)" for user "([^"]*)" if the file is also in the trashbin should be "([^"]*)" otherwise "([^"]*)"$/
*
* Note: this is a special step for an unusual bug combination.
* Delete it when the bug is fixed and the step is no longer needed.
*
* @param string|null $fileName
* @param string|null $user
* @param string|null $content
* @param string|null $alternativeContent
*
* @return void
* @throws JsonException
* @throws Exception
*/
public function contentOfFileForUserIfAlsoInTrashShouldBeOtherwise(
?string $fileName,
?string $user,
?string $content,
?string $alternativeContent
): void {
$isInTrash = $this->isInTrash($user, $fileName);
$user = $this->featureContext->getActualUsername($user);
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
if ($isInTrash) {
$this->featureContext->checkDownloadedContentMatches($content, '', $response);
} else {
$this->featureContext->checkDownloadedContentMatches($alternativeContent, '', $response);
}
}
/** /**
* @When /^user "([^"]*)" restores the (?:file|folder|entry) with original path "([^"]*)" using the trashbin API$/ * @When /^user "([^"]*)" restores the (?:file|folder|entry) with original path "([^"]*)" using the trashbin API$/
* *
-1
View File
@@ -21,7 +21,6 @@
use Behat\Gherkin\Node\PyStringNode; use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode; use Behat\Gherkin\Node\TableNode;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
use PHPUnit\Framework\Assert; use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;