Skip to content

Commit 446e962

Browse files
committed
Add tests for delete group endpoint
1 parent 79a4bb7 commit 446e962

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)