File tree Expand file tree Collapse file tree 9 files changed +30
-7
lines changed
tests/Feature/Controllers Expand file tree Collapse file tree 9 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,11 @@ protected function createPermissions()
61
61
protected function assignPermissionsToRoles ()
62
62
{
63
63
$ this ->roles ->get (Role::SUPER_ADMIN ->value )->givePermissionTo ($ this ->superAdminPermissions );
64
+ $ this ->roles ->get (Role::SUPER_ADMIN ->value )->givePermissionTo ($ this ->orgnaisationPermissions );
65
+ $ this ->roles ->get (Role::SUPER_ADMIN ->value )->givePermissionTo ($ this ->postPermissions );
64
66
65
- $ this ->roles ->get (Role::ADMIN ->value )->givePermissionTo ($ this ->postPermissions );
66
67
$ this ->roles ->get (Role::ADMIN ->value )->givePermissionTo ($ this ->orgnaisationPermissions );
68
+ $ this ->roles ->get (Role::ADMIN ->value )->givePermissionTo ($ this ->postPermissions );
67
69
68
70
$ this ->roles ->get (Role::USER ->value )->givePermissionTo ($ this ->postPermissions );
69
71
}
Original file line number Diff line number Diff line change 15
15
16
16
actingAs ($ user )
17
17
->get (route ('account.edit ' ))
18
+ ->assertOk ()
18
19
->assertInertia (
19
20
fn (Assert $ page ) => $ page
20
21
->component ('Account/Edit ' )
42
43
'password ' => 'newPassword#123 ' ,
43
44
])
44
45
->assertRedirectToRoute ('account.edit ' )
46
+ ->assertSessionDoesntHaveErrors ()
45
47
->assertSessionHas ('success ' , __ ('account.updated ' ));
46
48
47
49
expect ($ user ->refresh ())
62
64
]);
63
65
64
66
actingAs ($ user )
67
+ ->from (route ('account.edit ' ))
65
68
->patch (route ('account.update ' ), $ newData = [
66
69
'email ' => 'jim@test.com ' ,
67
70
])
68
- ->assertSessionHasErrors ('email ' );
71
+ ->assertSessionHasErrors ('email ' )
72
+ ->assertRedirectToRoute ('account.edit ' );
69
73
70
74
expect ($ user ->refresh ()->email )->not ()->toBe ($ newData ['email ' ]);
71
75
});
Original file line number Diff line number Diff line change 13
13
test ('Can access the verification page ' , function () {
14
14
actingAs (User::factory ()->unverified ()->create ())
15
15
->get (route ('verification.notice ' ))
16
+ ->assertOk ()
16
17
->assertInertia (
17
18
fn (Assert $ page ) => $ page
18
19
->component ('EmailVerification/Show ' )
32
33
'id ' => $ user ->getKey (),
33
34
'hash ' => sha1 ($ user ->getEmailForVerification ()),
34
35
]))
36
+ ->assertSessionDoesntHaveErrors ()
35
37
->assertRedirectToRoute ('home ' );
36
38
37
39
expect ($ user ->refresh ()->email_verified_at )->not ()->toBeNull ();
45
47
from (route ('verification.notice ' ))
46
48
->actingAs ($ user )
47
49
->post (route ('verification.send ' ))
50
+ ->assertSessionDoesntHaveErrors ()
48
51
->assertRedirectToRoute ('verification.notice ' );
49
52
50
53
Notification::assertSentTo ($ user , Illuminate \Auth \Notifications \VerifyEmail::class);
Original file line number Diff line number Diff line change 10
10
test ('Can access the home page ' , function () {
11
11
actingAs (User::factory ()->create ())
12
12
->get (route ('home ' ))
13
+ ->assertOk ()
13
14
->assertInertia (
14
15
fn (Assert $ page ) => $ page
15
16
->component ('Dashboard/Index ' )
Original file line number Diff line number Diff line change 37
37
'email ' => $ user ->email ,
38
38
'password ' => '12345 ' ,
39
39
])
40
+ ->assertSessionDoesntHaveErrors ()
40
41
->assertRedirectToRoute ('home ' );
41
42
42
43
assertAuthenticated ();
55
56
'password ' => '12345 ' ,
56
57
'redirect ' => $ redirect ,
57
58
])
59
+ ->assertSessionDoesntHaveErrors ()
58
60
->assertRedirect ($ redirect );
59
61
60
62
assertAuthenticated ();
69
71
'email ' => $ user ->email ,
70
72
'password ' => 'test ' ,
71
73
])
72
- ->assertsessionHasErrors ();
74
+ ->assertSessionHasErrors ();
73
75
74
76
assertGuest ();
75
77
});
Original file line number Diff line number Diff line change 10
10
test ('Can logout ' , function () {
11
11
actingAs (User::factory ()->create ())
12
12
->post (route ('logout ' ))
13
+ ->assertSessionDoesntHaveErrors ()
13
14
->assertRedirectToRoute ('login ' );
14
15
15
16
assertGuest ();
19
20
describe ('Guests ' , function () {
20
21
test ("Can't logout " , function () {
21
22
post (route ('logout ' ))
23
+ ->assertSessionDoesntHaveErrors ()
22
24
->assertRedirectToRoute ('login ' );
23
25
});
24
26
});
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
use App \Models \User ;
4
+ use Inertia \Testing \AssertableInertia as Assert ;
4
5
5
6
use function Pest \Laravel \actingAs ;
6
7
use function Pest \Laravel \from ;
23
24
test ('Can see the edit page for their current organisation ' , function () {
24
25
actingAs ($ this ->adminUser )
25
26
->get (route ('organisation.edit ' ))
26
- ->assertOk ();
27
+ ->assertOk ()
28
+ ->assertInertia (
29
+ fn (Assert $ page ) => $ page
30
+ ->component ('Organisation/Edit ' )
31
+ );
27
32
});
28
33
29
34
test ("Can update their organisation's name " , function () {
34
39
->patch (route ('organisation.update ' ), [
35
40
'name ' => 'New Name ' ,
36
41
])
42
+ ->assertSessionDoesntHaveErrors ()
37
43
->assertRedirectToRoute ('organisation.edit ' );
38
44
39
45
expect ($ this ->adminUser ->organisation ->refresh ()->name )->toBe ('New Name ' );
73
79
describe ('Guests ' , function () {
74
80
test ("Can't see the edit page of organisations " , function () {
75
81
get (route ('organisation.edit ' ))
76
- ->assertRedirect ( );
82
+ ->assertRedirectToRoute ( ' login ' );
77
83
});
78
84
79
85
test ("Can't update organisations " , function () {
80
86
patch (route ('organisation.edit ' ))
81
- ->assertRedirect ( );
87
+ ->assertRedirectToRoute ( ' login ' );
82
88
});
83
89
});
Original file line number Diff line number Diff line change 39
39
'email ' => $ email ,
40
40
'password ' => 'P$ssword12345# ' ,
41
41
])
42
+ ->assertSessionDoesntHaveErrors ()
42
43
->assertRedirectToRoute ('home ' );
43
44
44
45
assertDatabaseHas ('users ' , [
Original file line number Diff line number Diff line change 28
28
post (route ('password.store ' ), [
29
29
'email ' => $ user ->email ,
30
30
])
31
+ ->assertSessionDoesntHaveErrors ()
31
32
->assertRedirectToRoute ('login ' );
32
33
33
34
Notification::assertSentTo ($ user , ResetPassword::class);
40
41
->post (route ('password.store ' ), [
41
42
'email ' => fake ()->email (),
42
43
])
43
- ->assertsessionHasErrors ('email ' )
44
+ ->assertSessionHasErrors ('email ' )
44
45
->assertRedirectToRoute ('password ' );
45
46
46
47
Notification::assertNothingSent ();
75
76
'password ' => $ newPassword ,
76
77
'password_confirmation ' => $ newPassword ,
77
78
]))
79
+ ->assertSessionDoesntHaveErrors ()
78
80
->assertRedirectToRoute ('login ' );
79
81
});
You can’t perform that action at this time.
0 commit comments