create(); $post = Post::factory()->create(); $response = $this->actingAs($user) ->postJson("/api/posts/{$post->id}/comments", [ 'content' => 'Test Comment', ]); $response->assertStatus(200) ->assertJson([ 'message' => 'Comment added successfully', ]); $this->assertDatabaseHas('comments', [ 'content' => 'Test Comment', 'post_id' => $post->id, 'author_id' => $user->id, ]); } public function test_user_can_delete_own_comment(): void { $user = User::factory()->create(); $comment = Comment::factory()->create([ 'author_id' => $user->id, ]); $response = $this->actingAs($user) ->deleteJson("/api/comments/{$comment->id}"); $response->assertStatus(200) ->assertJson([ 'message' => 'Comment deleted successfully', ]); $this->assertDatabaseMissing('comments', [ 'id' => $comment->id, ]); } }