Looks like user is not created
$user = factory('App\User')->create();
dd($user); // null
Summer Sale! All accounts are 50% off this week.
I'm trying to run a simple Dusk test where I create a user, log in as that user, and then assert that the logged in user is an authenticated one. Here is the very simple code:
$user = factory('App\User')->create();
$this->browse(function (Browser $browser) use ($user){
$browser->loginAs($user)
->assertAuthenticated();
});
I'm getting the following error:
local.ERROR: Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given
The definition for SessionGuard::login():
/**
* Log a user into the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @return void
*/
public function login(AuthenticatableContract $user, $remember = false)
So I see that as the first parameter it takes a $user object that must implment the \Illuminate\Contracts\Auth\Authenticatable interface.
Now the User model uses the Illuminate\Foundation\Auth\User trait that implements the Illuminate\Contracts\Auth\Authenticatable interface (amongs other things).
So as far as I can see the requirements are met and it should work. Obviously I'm missing something here... Would welcome any suggestions on how to try and fix this. TIA.
Please or to participate in this conversation.