Laravel csrf validation failing during unit testing (Laravel 4.1)
I recently upgraded from Laravel 4.0 to 4.1 following the upgrade instructions, and now when unit testing my csrf tokens will not validate. I have posted code here: http://laravel.io/bin/7qRx
The csrf validation seems to work fine when browsing the site and submitting forms, however when I run the unit tests to validate the same forms, the csrf validation fails. It worked before the upgrade to 4.1.
I found a similar problem here, but also no solution listed. https://github.com/laravel/laravel/issues/2633
I found the solution. You have to add
to the setup() method. Solves session related problems when you call the routes.
Apparently Laravel starts the session when the route is called, and if it hasn't already been created, the previous session data is overwritten.
Found the solution based on what was posted here: Laravel 4 testing session in controllers [SOLVED]