File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1616 'sort ' => $ faker ->numberBetween (1 , 100 ),
1717 ];
1818});
19+
20+
21+ $ factory ->state (Permission::class, 'active ' , function () {
22+ return [
23+ 'status ' => 1 ,
24+ ];
25+ });
26+
27+ $ factory ->state (Permission::class, 'inactive ' , function () {
28+ return [
29+ 'status ' => 0 ,
30+ ];
31+ });
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Feature \Backend ;
4+
5+ use App \Models \Access \Permission \Permission ;
6+ use Illuminate \Support \Facades \Event ;
7+ use Tests \TestCase ;
8+
9+ class ManagePermissionsTest extends TestCase
10+ {
11+ /** @test */
12+ public function a_user_can_view_permissions ()
13+ {
14+ $ this ->actingAs ($ this ->admin )
15+ ->get (route ('admin.access.permission.index ' ))
16+ ->assertViewIs ('backend.access.permissions.index ' )
17+ ->assertSee (trans ('labels.backend.access.permissions.management ' ))
18+ ->assertSee ('Export ' )
19+ ->assertSee ('Action ' );
20+ }
21+
22+ /** @test */
23+ public function a_permission_requires_a_name ()
24+ {
25+ $ permission = make (Permission::class, ['name ' => null ])->toArray ();
26+
27+ return $ this ->withExceptionHandling ()
28+ ->actingAs ($ this ->admin )
29+ ->post (route ('admin.access.permission.store ' ), $ permission )
30+ ->assertSessionHasErrors ('name ' );
31+ }
32+
33+ /** @test */
34+ public function a_permission_requires_a_display_name ()
35+ {
36+ $ permission = make (Permission::class, ['display_name ' => null ])->toArray ();
37+
38+ return $ this ->withExceptionHandling ()
39+ ->actingAs ($ this ->admin )
40+ ->post (route ('admin.access.permission.store ' ), $ permission )
41+ ->assertSessionHasErrors ('display_name ' );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments