Source: paulund.co.uk

Laravel Testing Redirect
With Laravel it makes it really easy to test HTTP requests by using the trait MakesHttpRequests. This has all the methods you will need to run HTTP requests from your feature tests. One thing you will often come across in testing your application is when you need to test redirects.

There are a few methods you need to be aware of to be able to tests these: from() assertRedirect()

return response()->back(); To be able to test this you need to use the from() method on the MakesHttpRequests, this will tell Laravel where to redirect back to.
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