From 446e962a503078e0c5fabef90aac7ada21ecb6e2 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 16 Sep 2024 10:38:51 -0700 Subject: [PATCH] Add tests for delete group endpoint --- tests/Feature/Groups/Api/DeleteGroupTest.php | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/Feature/Groups/Api/DeleteGroupTest.php diff --git a/tests/Feature/Groups/Api/DeleteGroupTest.php b/tests/Feature/Groups/Api/DeleteGroupTest.php new file mode 100644 index 0000000000..8d057a7ed3 --- /dev/null +++ b/tests/Feature/Groups/Api/DeleteGroupTest.php @@ -0,0 +1,32 @@ +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]); + } +}