Home > Mobile >  How to logout user in Laravel functional tests?
How to logout user in Laravel functional tests?

Time:06-29

In Laravel feature tests,

Given that user has been programmatically logged in using

$this->actingAs(self::$user, 'api');

How would I logout this user?
actingAs does not accept null as first parameter.

CodePudding user response:

A good way to logout the user is

$guard = Mockery::mock(Guard::class);
$guard->expects('check')
        ->andReturns(false);

Auth::shouldReceive('guard')
       ->andReturns($guard);
  • Related