From c14a5b1d072efa1caed6d6b01a101280484d4bf7 Mon Sep 17 00:00:00 2001 From: Collin Henderson Date: Sun, 10 Mar 2024 19:03:34 -0400 Subject: [PATCH] Adds TagsController@destroy test --- .../TagsController/DestroyTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/Feature/Controllers/TagsController/DestroyTest.php diff --git a/tests/Feature/Controllers/TagsController/DestroyTest.php b/tests/Feature/Controllers/TagsController/DestroyTest.php new file mode 100644 index 00000000..d0e353f2 --- /dev/null +++ b/tests/Feature/Controllers/TagsController/DestroyTest.php @@ -0,0 +1,33 @@ +delete('/tags/1') + ->assertRedirect('/login'); + +it('deletes a tag', function () { + $this->login(); + + $tag = Tag::factory()->create(['name' => 'TypeScript', 'user_id' => auth()->id()]); + + $this + ->delete(route('tags.destroy', $tag)) + ->assertRedirect(route('dashboard.show')); + + $this->assertDatabaseMissing('tags', ['id' => $tag->id]); +}); + +it('automatically scopes the bound tag in the request to the authenticated user', function () { + $tag = Tag::factory()->create(); + + $this->login(); + + $this + ->delete(route('tags.destroy', $tag)) + ->assertNotFound(); + + $this->assertDatabaseHas('tags', ['id' => $tag->id]); +});