1 | <?php |
||
2 | |||
3 | namespace Ikechukwukalu\Requirepin\Tests; |
||
4 | |||
5 | use Illuminate\Foundation\Testing\RefreshDatabase; |
||
6 | use Illuminate\Support\Str; |
||
7 | use Illuminate\Support\Facades\Hash; |
||
8 | use Illuminate\Support\Facades\Notification; |
||
9 | use Ikechukwukalu\Requirepin\Models\TestUser; |
||
10 | use Ikechukwukalu\Requirepin\Notifications\PinChange; |
||
11 | |||
12 | class NotificationsTest extends TestCase |
||
13 | { |
||
14 | use RefreshDatabase; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
15 | |||
16 | public function test_fires_pin_change_notification(): void |
||
17 | { |
||
18 | Notification::fake(); |
||
19 | |||
20 | Notification::assertNothingSent(); |
||
21 | |||
22 | $user = TestUser::create([ |
||
23 | 'name' => str::random(), |
||
24 | 'email' => Str::random(40) . '@example.com', |
||
25 | 'password' => Hash::make('password'), |
||
26 | 'pin' => Hash::make('0000'), |
||
27 | ]); |
||
28 | |||
29 | $this->actingAs($user); |
||
30 | $user->notify(new PinChange()); |
||
31 | |||
32 | Notification::assertSentTo( |
||
33 | [$user], PinChange::class |
||
34 | ); |
||
35 | |||
36 | Notification::assertCount(1); |
||
37 | } |
||
38 | } |
||
39 |