added step to check notification with subject and resource (#6675)

This commit is contained in:
Karun Atreya
2023-07-26 10:07:45 +05:45
committed by GitHub
parent 2c36867629
commit 078c7e036c
2 changed files with 39 additions and 7 deletions
@@ -343,6 +343,38 @@ class NotificationContext implements Context {
);
}
/**
* @Then user :user should get a notification for resource :resource with subject :subject and message:
*
* @param string $user
* @param string $resource
* @param string $subject
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function userShouldGetNotificationForResourceWithMessage(string $user, string $resource, string $subject, TableNode $table):void {
$this->userListAllNotifications($user);
$notification = $this->filterResponseByNotificationSubjectAndResource($subject, $resource);
if (\count($notification) === 1) {
$actualMessage = str_replace(["\r", "\r"], " ", $notification[0]->message);
$expectedMessage = $table->getColumnsHash()[0]['message'];
Assert::assertSame(
$expectedMessage,
$actualMessage,
__METHOD__ . "expected message to be '$expectedMessage' but found'$actualMessage'"
);
$this->userDeletesNotificationOfResourceAndSubject($user, $resource, $subject);
$this->featureContext->theHTTPStatusCodeShouldBe(200);
} elseif (\count($notification) === 0) {
throw new \Exception("Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n$notification");
} else {
throw new \Exception("Response contains more than one notification with resource '$resource' and subject '$subject'.\n$notification");
}
}
/**
* @Then user :user should not have a notification related to resource :resource with subject :subject
*