refactoring FeatureContext.php file (#7548)

This commit is contained in:
nirajacharya2
2023-11-28 14:03:07 +05:45
committed by GitHub
parent 4a94388a25
commit 8a6fcc7b70
@@ -630,7 +630,7 @@ class FeatureContext extends BehatVariablesContext {
* @throws Exception
*/
public static function logStep(BeforeStepScope $scope): void {
$step = $scope->getStep()->getType() . " " . $scope->getStep()->getText();
$step = $scope->getStep()->getKeyword() . " " . $scope->getStep()->getText();
$logMessage = "\t### $step\n";
HttpLogger::writeLog(HttpLogger::getScenarioLogPath(), $logMessage);
}
@@ -1724,7 +1724,7 @@ class FeatureContext extends BehatVariablesContext {
];
}
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$loginUrl,
$this->getStepLineRef(),
null,
@@ -1734,8 +1734,8 @@ class FeatureContext extends BehatVariablesContext {
$config,
$this->cookieJar
);
$this->theHTTPStatusCodeShouldBeSuccess();
$this->extractRequestTokenFromResponse($this->response);
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
$this->extractRequestTokenFromResponse($response);
// Login and extract new token
$password = $this->getPasswordForUser($user);
@@ -1744,7 +1744,7 @@ class FeatureContext extends BehatVariablesContext {
'password' => $password,
'requesttoken' => $this->requestToken
];
$this->response = HttpRequestHelper::post(
$response = HttpRequestHelper::post(
$loginUrl,
$this->getStepLineRef(),
null,
@@ -1754,8 +1754,8 @@ class FeatureContext extends BehatVariablesContext {
$config,
$this->cookieJar
);
$this->theHTTPStatusCodeShouldBeSuccess();
$this->extractRequestTokenFromResponse($this->response);
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
$this->extractRequestTokenFromResponse($response);
}
/**
@@ -2358,8 +2358,8 @@ class FeatureContext extends BehatVariablesContext {
*
* @return void
*/
public function readFileInServerRootForCore(string $path): void {
$response = OcsApiHelper::sendRequest(
public function readFileInServerRootForCore(string $path): ResponseInterface {
return OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$this->getAdminUsername(),
$this->getAdminPassword(),
@@ -2367,7 +2367,6 @@ class FeatureContext extends BehatVariablesContext {
"/apps/testing/api/v1/file?file=$path",
$this->getStepLineRef()
);
$this->setResponse($response);
}
/**