Skip to content

Commit

Permalink
Add tests for delete group endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmoore committed Sep 16, 2024
1 parent 79a4bb7 commit 446e962
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Feature/Groups/Api/DeleteGroupTest.php
Original file line number Diff line number Diff line change
@@ -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]);
}
}

0 comments on commit 446e962

Please sign in to comment.