|
5 | 5 | namespace App\Tests\Functional; |
6 | 6 |
|
7 | 7 | use App\Tests\Support\FunctionalTester; |
| 8 | +use PHPUnit\Framework\AssertionFailedError; |
8 | 9 |
|
9 | 10 | final class NotifierCest |
10 | 11 | { |
11 | 12 | public function assertNotificationSubjectContains(FunctionalTester $I) |
12 | 13 | { |
13 | 14 | $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 | + }); |
16 | 19 | } |
17 | 20 |
|
18 | 21 | public function assertNotificationSubjectNotContains(FunctionalTester $I) |
19 | 22 | { |
20 | 23 | $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 | + }); |
23 | 28 | } |
24 | 29 |
|
25 | 30 | public function assertNotificationTransportIsEqual(FunctionalTester $I) |
26 | 31 | { |
27 | 32 | $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 | + }); |
30 | 37 | } |
31 | 38 |
|
32 | 39 | public function assertNotificationTransportIsNotEqual(FunctionalTester $I) |
33 | 40 | { |
34 | 41 | $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 | + }); |
37 | 46 | } |
38 | 47 |
|
39 | 48 | public function dontSeeNotificationIsSent(FunctionalTester $I) |
40 | 49 | { |
41 | 50 | $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 | + }); |
44 | 55 | } |
45 | 56 |
|
46 | 57 | public function grabLastSentNotification(FunctionalTester $I) |
47 | 58 | { |
48 | 59 | $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 | + }); |
51 | 64 | } |
52 | 65 |
|
53 | 66 | public function grabSentNotifications(FunctionalTester $I) |
54 | 67 | { |
55 | 68 | $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 | + }); |
59 | 74 | } |
60 | 75 |
|
61 | 76 | public function seeNotificationIsSent(FunctionalTester $I) |
62 | 77 | { |
63 | 78 | $I->registerUser('jane_doe@gmail.com', '123456', followRedirects: false); |
64 | | - $I->seeNotificationIsSent(); |
| 79 | + $I->expectThrowable(AssertionFailedError::class, function () use ($I) { |
| 80 | + $I->seeNotificationIsSent(); |
| 81 | + }); |
65 | 82 | } |
66 | 83 | } |
0 commit comments