How do you test databases, queues, events, notifications, and HTTP requests?
Answer
Clear, interview-ready explanation
Laravel feature tests can use database refresh or transaction traits, factories, seeders, and assertions such as assertDatabaseHas or assertDatabaseMissing to verify persisted state. For queues, events, notifications, mail, storage, and HTTP clients, Laravel provides fakes so tests can assert that an action was dispatched or sent without performing the real side effect.
HTTP endpoints are tested with helpers such as get, post, actingAs, and response assertions for status, JSON, redirects, validation errors, and views. Fakes should be used deliberately: keep a smaller set of integration tests for important real integrations, and assert meaningful payloads or state rather than only asserting that a facade method was called.