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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners