[tests-only][full-ci] removing the setresponse in given/then step in CheckSumContext and FavoritesContext (#7202)

* making helper function, checking and setting response in given step and when steo respectively

* returning response and using in given/then steps as required in favoritesContext

* set the returned response on SpaceContext

* changed to inline variable in some lines as required

* to check for the specific https response code
This commit is contained in:
Karun Atreya
2023-09-11 17:42:27 +05:45
committed by GitHub
parent b5dc207d42
commit 8d1b2e3343
3 changed files with 113 additions and 70 deletions
@@ -39,15 +39,14 @@ class FavoritesContext implements Context {
* @param string$user
* @param string $path
*
* @return void
* @return ResponseInterface
*/
public function userFavoritesElement(string $user, string $path):void {
$response = $this->changeFavStateOfAnElement(
public function userFavoritesElement(string $user, string $path):ResponseInterface {
return $this->changeFavStateOfAnElement(
$user,
$path,
1
);
$this->featureContext->setResponse($response);
}
/**
@@ -59,7 +58,7 @@ class FavoritesContext implements Context {
* @return void
*/
public function userFavoritesElementUsingWebDavApi(string $user, string $path):void {
$this->userFavoritesElement($user, $path);
$this->featureContext->setResponse($this->userFavoritesElement($user, $path));
}
/**
@@ -71,8 +70,7 @@ class FavoritesContext implements Context {
* @return void
*/
public function userHasFavoritedElementUsingWebDavApi(string $user, string $path):void {
$this->userFavoritesElement($user, $path);
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
$this->featureContext->theHTTPStatusCodeShouldBe(207, '', $this->userFavoritesElement($user, $path));
}
/**
@@ -83,10 +81,11 @@ class FavoritesContext implements Context {
* @return void
*/
public function theUserFavoritesElement(string $path):void {
$this->userFavoritesElement(
$response = $this->userFavoritesElement(
$this->featureContext->getCurrentUser(),
$path
);
$this->featureContext->setResponse($response);
}
/**
@@ -97,13 +96,14 @@ class FavoritesContext implements Context {
* @return void
*/
public function theUserHasFavoritedElement(string $path):void {
$this->userFavoritesElement(
$response = $this->userFavoritesElement(
$this->featureContext->getCurrentUser(),
$path
);
$this->featureContext->theHTTPStatusCodeShouldBe(
207,
"Expected response status code to be 207 (Multi-status), but not found! "
"Expected response status code to be 207 (Multi-status), but not found! ",
$response
);
}
@@ -111,15 +111,14 @@ class FavoritesContext implements Context {
* @param string $user
* @param string $path
*
* @return void
* @return ResponseInterface
*/
public function userUnfavoritesElement(string $user, string $path):void {
$response = $this->changeFavStateOfAnElement(
public function userUnfavoritesElement(string $user, string $path):ResponseInterface {
return $this->changeFavStateOfAnElement(
$user,
$path,
0
);
$this->featureContext->setResponse($response);
}
/**
@@ -131,7 +130,7 @@ class FavoritesContext implements Context {
* @return void
*/
public function userUnfavoritesElementUsingWebDavApi(string $user, string $path):void {
$this->userUnfavoritesElement($user, $path);
$this->featureContext->setResponse($this->userUnfavoritesElement($user, $path));
}
/**
@@ -143,8 +142,7 @@ class FavoritesContext implements Context {
* @return void
*/
public function userHasUnfavoritedElementUsingWebDavApi(string $user, string $path):void {
$this->userUnfavoritesElement($user, $path);
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
$this->featureContext->theHTTPStatusCodeShouldBe(207, '', $this->userUnfavoritesElement($user, $path));
}
/**
@@ -212,10 +210,10 @@ class FavoritesContext implements Context {
/**
* @param string $path
*
* @return void
* @return ResponseInterface
*/
public function theUserUnfavoritesElement(string $path):void {
$this->userUnfavoritesElement(
public function theUserUnfavoritesElement(string $path):ResponseInterface {
return $this->userUnfavoritesElement(
$this->featureContext->getCurrentUser(),
$path
);
@@ -229,7 +227,7 @@ class FavoritesContext implements Context {
* @return void
*/
public function theUserUnfavoritesElementUsingWebDavApi(string $path):void {
$this->theUserUnfavoritesElement($path);
$this->featureContext->setResponse($this->theUserUnfavoritesElement($path));
}
/**
@@ -240,8 +238,7 @@ class FavoritesContext implements Context {
* @return void
*/
public function theUserHasUnfavoritedElementUsingWebDavApi(string $path):void {
$this->theUserUnfavoritesElement($path);
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
$this->featureContext->theHTTPStatusCodeShouldBe(207, '', $this->theUserUnfavoritesElement($path));
}
/**