snipe-it/tests/Feature/Groups/Api/DeleteGroupsTest.php

35 lines
981 B
PHP
Raw Normal View History

2024-09-16 10:38:51 -07:00
<?php
namespace Tests\Feature\Groups\Api;
use App\Models\Group;
use App\Models\User;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
2024-09-16 14:38:38 -07:00
class DeleteGroupsTest extends TestCase implements TestsPermissionsRequirement
2024-09-16 10:38:51 -07:00
{
public function testRequiresPermission()
{
$group = Group::factory()->create();
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.groups.destroy', $group))
->assertForbidden();
2024-09-16 14:32:38 -07:00
$this->assertDatabaseHas('permission_groups', ['id' => $group->id]);
2024-09-16 10:38:51 -07:00
}
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]);
}
}