title: How to Test Laravel Socialite
body: <p>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 <code>driver</code> method, but when I run my test it tells me that I am trying to get value on null type. </p>
  
  <p>Below is the test I have written</p>
  
  <pre><code>public function testGithubLogin()
  {
      Socialite::shouldReceive('driver')
          -&gt;with('github')
          -&gt;once();
      $this-&gt;call('GET', '/github/authorize')-&gt;isRedirection();
  }
  </code></pre>
  
  <p>Below is the implementation of the test</p>
  
  <pre><code>public function authorizeProvider($provider)
  {
      return Socialite::driver($provider)-&gt;redirect();
  }
  </code></pre>
  
  <p>I understand why it might return such result because <code>Sociallite::driver($provider)</code> returns an instance of <code>Laravel\Socialite\Two\GithubProvider</code>, and considering that I am unable to instantiate this value it will be impossible to specify a return type. I need help to successfully test the controller. Thanks</p>