When running phpunit with --process-isolation flag I get this error:
LogicException: Session name cannot be empty, did you forget to call "parent::open()" in "Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler"?
When running without process isolation, the test passes.
After exploring where it fails, I found that the error is thrown when attempt() method is called:
if (auth()->attempt($this->credentials($request), $request->remember)) {
if ($request->isJson()) {
return response()->json([
'user' => auth()->user(),
'message' => __('You have been successfully logged in!'),
], 201);
}
return redirect()->intended(route($this->redirectTo));
}
5.4 is no longer supported. Kindly try this on a 5.5 install and let us know if the issue still persists.
Ok, upgraded to laravel 5.5.25 and phpunit 6.5.5 and the test passes.
Also I don't need to run --process-isolation because it uses so much less memory now. Almost 4 times less.
For anyone else struggling with this add the following to a service providers register method:
~~~ php
$this->app->extend('session.store', function (Store $store, Container $container) {
$handler = $store->getHandler();
$config = $container->make('config');
if ($handler instanceof NullSessionHandler) {
$handler->open(null, $config->get('auth.defaults.guard'));
}
return $store;
});
~~~
Most helpful comment
For anyone else struggling with this add the following to a service providers register method:
~~~ php
$this->app->extend('session.store', function (Store $store, Container $container) {
$handler = $store->getHandler();
$config = $container->make('config');
if ($handler instanceof NullSessionHandler) {
$handler->open(null, $config->get('auth.defaults.guard'));
}
~~~