I'm writing a test suite for a Laravel web application. I'm making assertions against an endpoint that uses Laravel Request validation to validate the user input. This automatically redirects the user back to the previous page.
$request->validate([
'name' => 'required',
'email' => 'required|email',
'timeslot' => 'required'
]);
Currently, I am asserting that I if I post invalid data to this endpoint, I receive a redirect status code back. This is fine, but I would also like to assert, more specifically, that the user is redirected back to the previous page.
I feel that in order to properly test this condition, I need to somehow 'push' a URL into my test suite's/application's browser history, then assert that the redirect URL is that same URL.
How can I do this?
Aucun commentaire:
Enregistrer un commentaire