From 32d2ee56bee24a57396c6f37fe7badefd9696a43 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Fri, 21 Jul 2023 14:22:11 +0545 Subject: [PATCH] throw exception --- .../bootstrap/NotificationContext.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/features/bootstrap/NotificationContext.php b/tests/acceptance/features/bootstrap/NotificationContext.php index 2858b576592..3fd6648e3ba 100644 --- a/tests/acceptance/features/bootstrap/NotificationContext.php +++ b/tests/acceptance/features/bootstrap/NotificationContext.php @@ -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,