TantraGyan
4 years ago

Laravel 5 unit testing

Posted 4 years ago by TantraGyan

How do I test form request validations in Laravel 5. In my unit test, I am asserting that, if validation fails, it should redirect to some route. I am assigning invalid data via Input::replace() To be clear, I am passing request validation via method injection and when I perform the test, it returns with the error that "Failed asserting that Symfony\Component\HttpFoundation\Response Object (...) is an instance of class "Illuminate\Http\RedirectResponse"." From Laravel 5, laravel itself redirects back to the previous page with error messages. In unit test, I am creating a POST request, but I suppose we are faking data via Input::replace(), it is not getting redirected properly or some blunder I am making here ? So, I am a bit stuck here..

Please sign in or create an account to participate in this conversation.