public function amLoggedAs($user, $driver = null)
    {
        $guard = $auth = $this->app['auth'];

        if (method_exists($auth, 'driver')) {
            $guard = $auth->driver($driver);
        }

        if (method_exists($auth, 'guard')) {
            $guard = $auth->guard($driver);
        }

        if ($user instanceof Authenticatable) {
            $guard->login($user);
            return;
        }

        $this->assertTrue($guard->attempt($user), 'Failed to login with credentials ' . json_encode($user));
    }
public function amLoggedAs($user, $driver = null)
    {
        $guard = $auth = $this->app['auth'];

        if (method_exists($auth, 'driver')) {
            $guard = $auth->driver($driver);
        }

        if (method_exists($auth, 'guard')) {
            $guard = $auth->guard($driver);
        }

        if ($user instanceof Authenticatable) {
            $guard->login($user);
            return;
        }

        $this->assertTrue($guard->attempt($user), 'Failed to login with credentials ' . json_encode($user));
    }
public function amLoggedAs ( $ user , $ driver = null ) { $ guard = $ auth = $ this -> app [ 'auth' ] ; if ( method_exists ( $ auth , 'driver' ) ) { $ guard = $ auth -> driver ( $ driver ) ; } if ( method_exists ( $ auth , 'guard' ) ) { $ guard = $ auth -> guard ( $ driver ) ; } if ( $ user instanceof Authenticatable ) { $ guard -> login ( $ user ) ; return ; } $ this -> assertTrue ( $ guard -> attempt ( $ user ) , 'Failed to login with credentials ' . json_encode ( $ user ) ) ; }
Set the currently logged in user for the application.
Takes either an object that implements the User interface or
an array of credentials.

``` php
<?php
// provide array of credentials
$I->amLoggedAs(['username' => 'jane@example.com', 'password' => 'password']);

// provide User object
$I->amLoggedAs( new User );

// can be verified with $I->seeAuthentication();
?>
```
@param  \Illuminate\Contracts\Auth\User|array $user
@param  string|null $driver The authentication driver for Laravel <= 5.1.*, guard name for Laravel >= 5.2
@return void
Set the currently logged in user for the application . Takes either an object that implements the User interface or an array of credentials .