Category: Laravel, Laravel

Posted on Mar2nd2021 by Matthias Noback Back then I was still advocating that you should unit-test your controllers and that setter injection is very helpful when replacing controller dependencies with test doubles.

And controllers shouldn't be unit tested, because: The alternative I mentioned in 2012 is to write functional tests for your controller.

He also mentioned that it's not "by the book", so here I'd like to take the time to explain what by the book would look like.

In this case it would help to create an adapter test for the controller.
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