Add tests for space notification (#6372)

This commit is contained in:
Amrita
2023-06-08 16:59:45 +05:45
committed by GitHub
parent aac7816a49
commit c750d6677a
6 changed files with 538 additions and 182 deletions
@@ -115,6 +115,28 @@ class NotificationContext implements Context {
Assert::assertNull($notifications, "response should not contain any notification");
}
/**
* @Then /^user "([^"]*)" should have "([^"]*)" notifications$/
*
* @param string $user
* @param int $numberOfNotification
*
* @return void
* @throws Exception
*/
public function userShouldHaveNotifications(string $user, int $numberOfNotification): void {
if (!isset($this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data)) {
throw new Exception("Notification is empty");
}
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent()->ocs->data;
$actualNumber = \count($responseBody);
Assert::assertEquals(
$numberOfNotification,
$actualNumber,
"Expected number of notification was '$numberOfNotification', but got '$actualNumber'"
);
}
/**
* @Then /^the JSON response should contain a notification message with the subject "([^"]*)" and the message-details should match$/
*
@@ -26,6 +26,7 @@ use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Psr\Http\Message\ResponseInterface;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\ExpectationFailedException;
use TestHelpers\OcsApiHelper;
use TestHelpers\SharingHelper;
use TestHelpers\HttpRequestHelper;
@@ -3449,7 +3450,7 @@ trait Sharing {
Assert::assertEquals($row['path'], $share['path']);
$found = true;
break;
} catch (PHPUnit\Framework\ExpectationFailedException $e) {
} catch (ExpectationFailedException $e) {
}
}
if (!$found) {
@@ -2132,6 +2132,28 @@ class SpacesContext implements Context {
$this->ocsContext->theOCSStatusCodeShouldBe($expectedOCSStatus, "Expected OCS response status code $expectedOCSStatus");
}
/**
* @Given user :user has unshared a space :spaceName shared with :recipient
*
* @param string $user
* @param string $spaceName
* @param string $recipient
*
* @return void
* @throws GuzzleException
*/
public function userHasUnsharedASpaceSharedWith(
string $user,
string $spaceName,
string $recipient
): void {
$this->sendUnshareSpaceRequest($user, $spaceName, $recipient);
$this->featureContext->theHTTPStatusCodeShouldBe(
200,
"Expected response status code should be 200"
);
}
/**
* @When /^user "([^"]*)" unshares a space "([^"]*)" to (?:user|group) "([^"]*)"$/
*
@@ -2187,6 +2209,26 @@ class SpacesContext implements Context {
);
}
/**
* @Given /^user "([^"]*)" has deleted a space "([^"]*)"$/
*
* @param string $user
* @param string $spaceName
*
* @return void
* @throws GuzzleException
*/
public function userHasDeletedASpaceOwnedByUser(
string $user,
string $spaceName
):void {
$this->sendDeleteSpaceRequest($user, $spaceName);
$this->featureContext->theHTTPStatusCodeShouldBe(
204,
"Expected response status code should be 200"
);
}
/**
* @When /^user "([^"]*)" disables a space "([^"]*)"$/
* @When /^user "([^"]*)" (?:disables|tries to disable) a space "([^"]*)" owned by user "([^"]*)"$/