Skip to content

Instantly share code, notes, and snippets.

@MiloudiMohamed
Created February 8, 2019 09:19
Show Gist options
  • Save MiloudiMohamed/a3410f08121deac599e0168a4eb6e6ce to your computer and use it in GitHub Desktop.
Save MiloudiMohamed/a3410f08121deac599e0168a4eb6e6ce to your computer and use it in GitHub Desktop.
Socialite mocking script for laravel
<?php
// This is Just a reference for this gist "https://gist.github.com/jlmaners/eb5f9f7bf6ca7f6c3ec02270d9959876" in case it deleted
$mockSocialite = \Mockery::mock('Laravel\Socialite\Contracts\Factory');
$this->app['Laravel\Socialite\Contracts\Factory'] = $mockSocialite;
$abstractUser = Mockery::mock('Laravel\Socialite\Two\User');
$abstractUser
->shouldReceive('getId')
->andReturn(rand())
->shouldReceive('getName')
->andReturn(str_random(10))
->shouldReceive('getEmail')
->andReturn($username.'@ncsu.edu')
->shouldReceive('getAvatar')
->andReturn('https://en.gravatar.com/userimage');
$provider = Mockery::mock('Laravel\Socialite\Contract\Provider');
$provider->shouldReceive('user')->andReturn($abstractUser);
$mockSocialite->shouldReceive('driver')->andReturn($provider);
$response = $this->get('/login/google/callback');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment