From ad55d98363391158de151666315bb4bd29f65f76 Mon Sep 17 00:00:00 2001 From: d-mitrofanov-v Date: Fri, 28 Nov 2025 07:03:27 +0200 Subject: [PATCH 1/2] expect throwable for 5.4 in notifier assertions --- tests/Functional/NotifierCest.php | 49 +++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/tests/Functional/NotifierCest.php b/tests/Functional/NotifierCest.php index 0f3e250..32563b0 100644 --- a/tests/Functional/NotifierCest.php +++ b/tests/Functional/NotifierCest.php @@ -5,62 +5,79 @@ namespace App\Tests\Functional; use App\Tests\Support\FunctionalTester; +use PHPUnit\Framework\Error\Warning; final class NotifierCest { public function assertNotificationSubjectContains(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $notification = $I->getNotifierMessage(); - $I->assertNotificationSubjectContains($notification, 'created!'); + $I->expectThrowable(Warning::class, function () { + $notification = $I->getNotifierMessage(); + $I->assertNotificationSubjectContains($notification, 'created!'); + }); } public function assertNotificationSubjectNotContains(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $notification = $I->getNotifierMessage(); - $I->assertNotificationSubjectNotContains($notification, 'Account not created!'); + $I->expectThrowable(Warning::class, function () { + $notification = $I->getNotifierMessage(); + $I->assertNotificationSubjectNotContains($notification, 'Account not created!'); + }); } public function assertNotificationTransportIsEqual(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $notification = $I->getNotifierMessage(); - $I->assertNotificationTransportIsEqual($notification); + $I->expectThrowable(Warning::class, function () { + $notification = $I->getNotifierMessage(); + $I->assertNotificationTransportIsEqual($notification); + }); } public function assertNotificationTransportIsNotEqual(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $notification = $I->getNotifierMessage(); - $I->assertNotificationTransportIsNotEqual($notification, 'chat'); + $I->expectThrowable(Warning::class, function () { + $notification = $I->getNotifierMessage(); + $I->assertNotificationTransportIsNotEqual($notification, 'chat'); + }); } public function dontSeeNotificationIsSent(FunctionalTester $I) { $I->registerUser('john_doe@gmail.com', '123456', followRedirects: false); - // There is already an account with this notification - $I->dontSeeNotificationIsSent(); + $I->expectThrowable(Warning::class, function () { + // There is already an account with this notification + $I->dontSeeNotificationIsSent(); + }); } public function grabLastSentNotification(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $notification = $I->grabLastSentNotification(); - $I->assertSame('Account created!', $notification->getSubject()); + $I->expectThrowable(Warning::class, function () { + $notification = $I->grabLastSentNotification(); + $I->assertSame('Account created!', $notification->getSubject()); + }); } public function grabSentNotifications(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $notifications = $I->grabSentNotifications(); - $subject = $notifications[0]->getSubject(); - $I->assertSame('Account created!', $subject); + $I->expectThrowable(Warning::class, function () { + $notifications = $I->grabSentNotifications(); + $subject = $notifications[0]->getSubject(); + $I->assertSame('Account created!', $subject); + }); } public function seeNotificationIsSent(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->seeNotificationIsSent(); + $I->expectThrowable(Warning::class, function () { + $I->seeNotificationIsSent(); + }); } } From 53b196795dc6e27a11cd7cf5bf77ff3f7655f6d1 Mon Sep 17 00:00:00 2001 From: d-mitrofanov-v Date: Fri, 28 Nov 2025 07:16:21 +0200 Subject: [PATCH 2/2] expect throwable for 5.4 in notifier assertions --- tests/Functional/NotifierCest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Functional/NotifierCest.php b/tests/Functional/NotifierCest.php index 32563b0..6b20f17 100644 --- a/tests/Functional/NotifierCest.php +++ b/tests/Functional/NotifierCest.php @@ -5,14 +5,14 @@ namespace App\Tests\Functional; use App\Tests\Support\FunctionalTester; -use PHPUnit\Framework\Error\Warning; +use PHPUnit\Framework\AssertionFailedError; final class NotifierCest { public function assertNotificationSubjectContains(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $notification = $I->getNotifierMessage(); $I->assertNotificationSubjectContains($notification, 'created!'); }); @@ -21,7 +21,7 @@ public function assertNotificationSubjectContains(FunctionalTester $I) public function assertNotificationSubjectNotContains(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $notification = $I->getNotifierMessage(); $I->assertNotificationSubjectNotContains($notification, 'Account not created!'); }); @@ -30,7 +30,7 @@ public function assertNotificationSubjectNotContains(FunctionalTester $I) public function assertNotificationTransportIsEqual(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $notification = $I->getNotifierMessage(); $I->assertNotificationTransportIsEqual($notification); }); @@ -39,7 +39,7 @@ public function assertNotificationTransportIsEqual(FunctionalTester $I) public function assertNotificationTransportIsNotEqual(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $notification = $I->getNotifierMessage(); $I->assertNotificationTransportIsNotEqual($notification, 'chat'); }); @@ -48,7 +48,7 @@ public function assertNotificationTransportIsNotEqual(FunctionalTester $I) public function dontSeeNotificationIsSent(FunctionalTester $I) { $I->registerUser('john_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { // There is already an account with this notification $I->dontSeeNotificationIsSent(); }); @@ -57,7 +57,7 @@ public function dontSeeNotificationIsSent(FunctionalTester $I) public function grabLastSentNotification(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $notification = $I->grabLastSentNotification(); $I->assertSame('Account created!', $notification->getSubject()); }); @@ -66,7 +66,7 @@ public function grabLastSentNotification(FunctionalTester $I) public function grabSentNotifications(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $notifications = $I->grabSentNotifications(); $subject = $notifications[0]->getSubject(); $I->assertSame('Account created!', $subject); @@ -76,7 +76,7 @@ public function grabSentNotifications(FunctionalTester $I) public function seeNotificationIsSent(FunctionalTester $I) { $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); - $I->expectThrowable(Warning::class, function () { + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { $I->seeNotificationIsSent(); }); }