diff --git a/tests/Functional/NotifierCest.php b/tests/Functional/NotifierCest.php index 0f3e250..6b20f17 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\AssertionFailedError; 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(AssertionFailedError::class, function () use ($I) { + $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(AssertionFailedError::class, function () use ($I) { + $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(AssertionFailedError::class, function () use ($I) { + $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(AssertionFailedError::class, function () use ($I) { + $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(AssertionFailedError::class, function () use ($I) { + // 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(AssertionFailedError::class, function () use ($I) { + $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(AssertionFailedError::class, function () use ($I) { + $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(AssertionFailedError::class, function () use ($I) { + $I->seeNotificationIsSent(); + }); } }