title: Failing unit testing of controller to check successful login in laravel 4.2
body: <p>I am testing whether a successful log in happens or not. For that I am checking,</p>
  
  <ul>
  <li>If successfully logged in <br/></li>
  <li>Application should redirect to dashboard<br/></li>
  </ul>
  
  <p>For that my <code>controller</code> looks like this</p>
  
  <pre><code>public function loginPost(){
  
      if (Auth::attempt(array(
          'email'     =&gt; Input::get('email'),
          'password'  =&gt; Input::get('password')
      ))){
          return Redirect::intended(route('dashboard'));
      }
  
      return Redirect::route('login')             
                          -&gt;withInput()
                          -&gt;with('errorMessage', 'Failed');
  }
  </code></pre>
  
  <p>And my <code>test</code> looks like this</p>
  
  <pre><code>public function testLoginSuccess(){
       $input = [
           'email'                 =&gt; 'xyz@gmail.com',
           'password'              =&gt; 'computer'
       ];
  
       Input::replace($input);
  
       Auth::shouldReceive('attempt')
             -&gt;with($input)
             -&gt;once()
             -&gt;andReturn(true);
  
       $this-&gt;call('POST', 'login', $input);
  
       $this-&gt;assertRedirectedToRoute('dashboard');
   }
  </code></pre>
  
  <p>Although this works in browser. But while testing, it fails with the message:</p>
  
  <blockquote>
    <p>BadMethodCallException: Method Mockery_0_Illuminate_Auth_AuthManager::check() does not exist on this mock object</p>
  </blockquote>