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

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