Skip to content

Commit

Permalink
throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
SwikritiT committed Jul 21, 2023
1 parent f1af8a7 commit 32d2ee5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/acceptance/features/bootstrap/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,25 +315,28 @@ public function filterResponseByNotificationSubjectAndResource(string $subject,
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function userShouldGetANotificationWithMessage(string $user, string $subject, TableNode $table):void {
$count = 0;
$this->userListAllNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200);
$this->userListAllNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200);
// sometimes the test might try to get notification before the notification is created by the server
// in order to prevent test from failing because of that list the notifications again
// in order to prevent test from failing because of that try to list the notifications again
while (!isset($this->filterResponseAccordingToNotificationSubject($subject)->message) && $count <= 5) {
if ($count > 0)\sleep(1);
if ($count > 0) {
\sleep(1);
}
$this->featureContext->setResponse(null);
$this->userListAllNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200);
++$count;
}
if (isset($this->filterResponseAccordingToNotificationSubject($subject)->message)){
$actualMessage = str_replace(["\r", "\n"], " ", $this->filterResponseAccordingToNotificationSubject($subject)->message);
} else {
throw new \Exception("Notification was not found even after retrying for 5 seconds");
}
if (isset($this->filterResponseAccordingToNotificationSubject($subject)->message)) {
$actualMessage = str_replace(["\r", "\n"], " ", $this->filterResponseAccordingToNotificationSubject($subject)->message);
} else {
throw new \Exception("Notification was not found even after retrying for 5 seconds.");
}
$expectedMessage = $table->getColumnsHash()[0]['message'];
Assert::assertSame(
$expectedMessage,
Expand Down

0 comments on commit 32d2ee5

Please sign in to comment.