count(3)->create(); $response = $this->getJson('/api/blog/categories'); $response->assertStatus(200); } public function test_can_get_single_category() { $category = Category::factory()->create(); $response = $this->getJson("/api/blog/categories/{$category->id}"); $response->assertStatus(200); } public function test_can_get_category_posts() { $category = Category::factory()->create(); $response = $this->getJson("/api/blog/categories/{$category->slug}/posts"); $response->assertStatus(200) ->assertJsonStructure(['category', 'posts', 'meta', 'links']); } public function test_can_create_category() { $response = $this->postJson('/api/blog/categories', [ 'name' => 'Tech', 'slug' => 'tech', ]); $response->assertStatus(201); $this->assertDatabaseHas('categories', ['slug' => 'tech']); } public function test_can_delete_category() { $category = Category::factory()->create(); $response = $this->deleteJson("/api/blog/categories/{$category->id}"); $response->assertStatus(200); $this->assertDatabaseMissing('categories', ['id' => $category->id]); } }