add tests

This commit is contained in:
Michael Barz
2022-01-16 11:57:57 +01:00
parent f7bf42bce0
commit 1db13d8a39
3 changed files with 90 additions and 2 deletions
@@ -350,6 +350,26 @@ class SpacesContext implements Context {
$this->rememberTheAvailableSpaces();
}
/**
* @When /^user "([^"]*)" lists all available spaces via the GraphApi with query "([^"]*)"$/
*
* @param string $user
* @param string $query
*
* @return void
*
* @throws GuzzleException
*/
public function theUserListsAllHisAvailableSpacesUsingTheGraphApiWithFilter(string $user, string $query): void {
$this->featureContext->setResponse(
$this->listSpacesRequest(
$user,
$this->featureContext->getPasswordForUser($user),
"?". $query
)
);
}
/**
* @When /^user "([^"]*)" creates a space "([^"]*)" of type "([^"]*)" with the default quota using the GraphApi$/
*
@@ -659,7 +679,7 @@ class SpacesContext implements Context {
}
/**
* @Then /^the json responded should not contain a space "([^"]*)"$/
* @Then /^the json responded should not contain a space with name "([^"]*)"$/
*
* @param string $spaceName
*
@@ -672,6 +692,45 @@ class SpacesContext implements Context {
Assert::assertEmpty($this->getSpaceByNameFromResponse($spaceName), "space $spaceName should not be available for a user");
}
/**
* @Then /^the json responded should (not|only|)\s?contain spaces of type "([^"]*)"$/
*
* @param string $shoulOrNot (not|only|)
* @param string $type
*
* @return void
* @throws Exception
*/
public function jsonRespondedShouldNotContainSpaceType(
string $onlyOrNot,
string $type
): void {
Assert::assertNotEmpty(
$spaces = json_decode(
(string)$this->featureContext
->getResponse()->getBody(),
true,
512,
JSON_THROW_ON_ERROR
)
);
$matches = [];
foreach($spaces["value"] as $space) {
if($onlyOrNot === "not") {
Assert::assertNotEquals($space["driveType"], $type);
}
if($onlyOrNot === "only") {
Assert::assertEquals($space["driveType"], $type);
}
if($onlyOrNot === "" && $space["driveType"] === $type) {
$matches[] = $space;
}
}
if($onlyOrNot === "") {
Assert::assertNotEmpty($matches);
}
}
/**
* @param string $shouldOrNot (not|)
* @param TableNode $expectedFiles