File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Feature \Groups \Api ;
4
+
5
+ use App \Models \Group ;
6
+ use App \Models \User ;
7
+ use Tests \Concerns \TestsPermissionsRequirement ;
8
+ use Tests \TestCase ;
9
+
10
+ class DeleteGroupTest extends TestCase implements TestsPermissionsRequirement
11
+ {
12
+ public function testRequiresPermission ()
13
+ {
14
+ $ group = Group::factory ()->create ();
15
+
16
+ $ this ->actingAsForApi (User::factory ()->create ())
17
+ ->deleteJson (route ('api.groups.destroy ' , $ group ))
18
+ ->assertForbidden ();
19
+ }
20
+
21
+ public function testCanDeleteGroup ()
22
+ {
23
+ $ group = Group::factory ()->create ();
24
+
25
+ // only super admins can delete groups
26
+ $ this ->actingAsForApi (User::factory ()->superuser ()->create ())
27
+ ->deleteJson (route ('api.groups.destroy ' , $ group ))
28
+ ->assertStatusMessageIs ('success ' );
29
+
30
+ $ this ->assertDatabaseMissing ('permission_groups ' , ['id ' => $ group ->id ]);
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments