Source: christoph-rumpel.com

What You Can Test In A Laravel App
A common challenge in testing is not HOW to test something, but WHAT you can test. I have made a list of all the things I like to test in my applications.

Testing page response is one of the simplest tests to write; still, it is extremely useful.

it('gives back a successful response for home page', function () { $this->get('/')->assertOk(); }); It's a straightforward test, but it is crucial to know your home page does not throw an error.

it('sends email to podcast author', function() { Mail::fake(); $podcast = Podcast::factory()->create(); $this->post(route('publish-podcast', $podcast)); Mail::assertSent(PodcastPublishedMail::class); }); Always run the Mail::fake() method at the beginning of your tests when testing emails.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners