mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add tests for delete group endpoint
This commit is contained in:
parent
79a4bb7316
commit
446e962a50
32
tests/Feature/Groups/Api/DeleteGroupTest.php
Normal file
32
tests/Feature/Groups/Api/DeleteGroupTest.php
Normal 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]);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue