Although this is a delayed response, hopefully it can partially help others.
Using the "Auth::login" or "Auth::loginUsingId" is not going to help - as that's logging in via the command line part of behat, whereas the broswer side (I imagine you're using Mink or something?) does not get that session data, so it is not logged in for that part.
I'm still trying to figure out how it can be done, but will let you know if I find out.
I wrote an article on how to set up the php testing framework Behat in order to use it with the Laravel framework in a Homestead development environment. It mentions the problems one faces when testing authentication in a testing environment.
I hope this helps.
I just blogged about how to share set a session when using a separate server with Behat. The approach can be used with Homestead, Artisan Serve or any other separate server.
It involves passing the session cookie to the Goutte or Selenium session.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us
The Laravel portal for problem solving, knowledge sharing and community building.