test_fires_pin_change_notification()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 21
rs 9.8666
cc 1
nc 1
nop 0
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
The trait Illuminate\Foundation\Testing\RefreshDatabase requires some properties which are not provided by Ikechukwukalu\Requirepin\Tests\NotificationsTest: $seeder, $seed, $connectionsToTransact, $dropTypes, $dropViews
Loading history...
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