Skip to content

Commit bd5acc3

Browse files
[5.4] Expect throwable in notifier cest (#36)
* expect throwable for 5.4 in notifier assertions * expect throwable for 5.4 in notifier assertions
1 parent 61af014 commit bd5acc3

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

tests/Functional/NotifierCest.php

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,79 @@
55
namespace App\Tests\Functional;
66

77
use App\Tests\Support\FunctionalTester;
8+
use PHPUnit\Framework\AssertionFailedError;
89

910
final class NotifierCest
1011
{
1112
public function assertNotificationSubjectContains(FunctionalTester $I)
1213
{
1314
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
14-
$notification = $I->getNotifierMessage();
15-
$I->assertNotificationSubjectContains($notification, 'created!');
15+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
16+
$notification = $I->getNotifierMessage();
17+
$I->assertNotificationSubjectContains($notification, 'created!');
18+
});
1619
}
1720

1821
public function assertNotificationSubjectNotContains(FunctionalTester $I)
1922
{
2023
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
21-
$notification = $I->getNotifierMessage();
22-
$I->assertNotificationSubjectNotContains($notification, 'Account not created!');
24+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
25+
$notification = $I->getNotifierMessage();
26+
$I->assertNotificationSubjectNotContains($notification, 'Account not created!');
27+
});
2328
}
2429

2530
public function assertNotificationTransportIsEqual(FunctionalTester $I)
2631
{
2732
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
28-
$notification = $I->getNotifierMessage();
29-
$I->assertNotificationTransportIsEqual($notification);
33+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
34+
$notification = $I->getNotifierMessage();
35+
$I->assertNotificationTransportIsEqual($notification);
36+
});
3037
}
3138

3239
public function assertNotificationTransportIsNotEqual(FunctionalTester $I)
3340
{
3441
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
35-
$notification = $I->getNotifierMessage();
36-
$I->assertNotificationTransportIsNotEqual($notification, 'chat');
42+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
43+
$notification = $I->getNotifierMessage();
44+
$I->assertNotificationTransportIsNotEqual($notification, 'chat');
45+
});
3746
}
3847

3948
public function dontSeeNotificationIsSent(FunctionalTester $I)
4049
{
4150
$I->registerUser('john_doe@gmail.com', '123456', followRedirects: false);
42-
// There is already an account with this notification
43-
$I->dontSeeNotificationIsSent();
51+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
52+
// There is already an account with this notification
53+
$I->dontSeeNotificationIsSent();
54+
});
4455
}
4556

4657
public function grabLastSentNotification(FunctionalTester $I)
4758
{
4859
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
49-
$notification = $I->grabLastSentNotification();
50-
$I->assertSame('Account created!', $notification->getSubject());
60+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
61+
$notification = $I->grabLastSentNotification();
62+
$I->assertSame('Account created!', $notification->getSubject());
63+
});
5164
}
5265

5366
public function grabSentNotifications(FunctionalTester $I)
5467
{
5568
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
56-
$notifications = $I->grabSentNotifications();
57-
$subject = $notifications[0]->getSubject();
58-
$I->assertSame('Account created!', $subject);
69+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
70+
$notifications = $I->grabSentNotifications();
71+
$subject = $notifications[0]->getSubject();
72+
$I->assertSame('Account created!', $subject);
73+
});
5974
}
6075

6176
public function seeNotificationIsSent(FunctionalTester $I)
6277
{
6378
$I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false);
64-
$I->seeNotificationIsSent();
79+
$I->expectThrowable(AssertionFailedError::class, function () use ($I) {
80+
$I->seeNotificationIsSent();
81+
});
6582
}
6683
}

0 commit comments

Comments
 (0)