Add tests for delete group endpoint

This commit is contained in:
Marcus Moore 2024-09-16 10:38:51 -07:00
parent 79a4bb7316
commit 446e962a50
No known key found for this signature in database

View file

@ -0,0 +1,32 @@
<?php
namespace Tests\Feature\Groups\Api;
use App\Models\Group;
use App\Models\User;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
class DeleteGroupTest extends TestCase implements TestsPermissionsRequirement
{
public function testRequiresPermission()
{
$group = Group::factory()->create();
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.groups.destroy', $group))
->assertForbidden();
}
public function testCanDeleteGroup()
{
$group = Group::factory()->create();
// only super admins can delete groups
$this->actingAsForApi(User::factory()->superuser()->create())
->deleteJson(route('api.groups.destroy', $group))
->assertStatusMessageIs('success');
$this->assertDatabaseMissing('permission_groups', ['id' => $group->id]);
}
}