What was your solution to this?
Nov 19, 2017
4
Level 9
“Your session has expired” when testing with user in Laravel Spark
[Posted this in the Spark channel too.]
In Spark on Laravel 5.5, I have this test:
$this->be(factory('App\User')->create());
$thing= factory('App\Thing')->create();
$response = $this->get('/things');
$response->assertSee($thing->title);
When I run it with PHPUnit it fails, and among the HTML output is:
<div class="modal-body">
Your session has expired. Please login again to continue.
</div>
The route it is hitting has no middleware - instead the middleware's in the controller:
public function __construct()
{
$this->middleware('auth');
}
But I get the same error when I remove this function.
Other things I've tried:
- Using
WithoutMiddleware - Using MySQL instead of sqlite-in-memory as test db
- Adding
trial_ends_atfield to User factory - Adding
<env name="CASHIER_ENV" value="testing"/>tophpunit.xml, so that it matches the Spark tests config - Testing with a clean install of Laravel/Spark. Same error.
Please or to participate in this conversation.