I have an application that makes use of socialite, I want to create test for Github authentication, So I used Socialite Facade to mock call to the Socialite driver
$provider = Mockery::mock('Laravel\Socialite\Contracts\Provider');
$provider->shouldReceive('redirect')->andReturn('Redirected');
$providerName = class_basename($provider);
//Call your model factory here
$socialAccount = factory('LearnCast\User')->create(['provider' => $providerName]);
$abstractUser = Mockery::mock('Laravel\Socialite\Two\User');
// Get the api user object here
$abstractUser->shouldReceive('getId')
->andReturn($socialAccount->provider_user_id)
->shouldReceive('getEmail')
->andReturn(str_random(10).'@noemail.app')
->shouldReceive('getNickname')
->andReturn('Laztopaz')
->shouldReceive('getAvatar')
->andReturn('https://en.gravatar.com/userimage');
$provider = Mockery::mock('Laravel\Socialite\Contracts\Provider');
$provider->shouldReceive('user')->andReturn($abstractUser);
Socialite::shouldReceive('driver')->with('facebook')->andReturn($provider);
// After Oauth redirect back to the route
$this->visit('/auth/facebook/callback')
// See the page that the user login into
->seePageIs('/');
Note: use the socialite package at the top of your class
use Laravel\Socialite\Facades\Socialite;
I had the same problem, but I was able to solve it using the technique above; @ceejayoz. I hope this helps.