Not sure but are you using WithoutMiddleware ? It disable session, so maybe thats why $error is not populated.
PHPUnit throwing $errors undefined
PHPUnit error. Just submitting a form with it
exception 'ErrorException' with message 'Undefined variable: errors' in /Users/ben/Sites/projects/laravel/storage/framework/views/6881477b204dc4f1b9ef4ea57a7c09ab:30
View line 30
<div class="form-group row{{ ($errors->has('heading') ? ' has-danger' : '') }}">
I've had a search but nothing really solid on why or how to get around it. Anyone have any ideas?
Maybe this... why do we have to use @if etc... https://laracasts.com/discuss/channels/testing/in-form-submit-testing-undefined-variable-errors
Right, it seems I was leading myself up the garden path there. The thing to do to avoid all this, is to continue to use the Middleware and then swap out the middleware you wish not to use with a dummy middleware that always passes.
namespace App\Http\Middleware;
use Closure;
class DummyMiddleware
{
public function handle($request, Closure $next)
{
return $next($request);
}
}
And within the test, swap out the VerifyCsrfToken middleware with:
$this->app->instance(\App\Http\Middleware\VerifyCsrfToken::class, new DummyMiddleware());
Thanks to @adamwathan" target="_blank">https://laracasts.com/@adamwathan for this tip.
Good luck!
Please or to participate in this conversation.