title: Laravel Testing - Throwing exception with Mockery
body: <p>I'm very new to Laravel and unit testing in general. I'm trying to write some tests for my AccountController and I've run into a road block. </p>
  
  <p>I'm using Sentry to handle users and groups in the site. I'm trying to test that my controller is handling exceptions thrown by Sentry properly. So my controller method that handles the login POST looks like this:</p>
  
  <pre><code>public function postLogin(){
  
      $credentials = array(
          'email' =&gt; Input::get('email'),
          'password' =&gt; Input::get('password')
      );
  
      try{
          $user = $this-&gt;authRepo-&gt;authenticate($credentials, true);
          return Redirect::route('get_posts');
      }
      catch (Exception $e){
          $message = $this-&gt;getLoginErrorMessage($e);
          return View::make('login', array('errorMsg' =&gt; $message));
      }
  }
  </code></pre>
  
  <p>authRepository is just a repository that uses Sentry to handle authentication. Now I want to test that when an email address is not specified a LoginRequiredException is thrown and the user sees the error message. Here is my test:</p>
  
  <pre><code>public function testPostLoginNoEmailSpecified(){
  
      $args = array(
          'email' =&gt; 'test@test.com'
      );
  
      $this-&gt;authMock
          -&gt;shouldReceive('authenticate')
          -&gt;once()
          -&gt;andThrow(new Cartalyst\Sentry\Users\LoginRequiredException);
  
      $this-&gt;action('POST', 'MyApp\Controllers\AccountController@postLogin', $args);
  
      $this-&gt;assertViewHas('errorMsg', 'Please enter your email address.');
  }
  </code></pre>
  
  <p>However, the test is not passing. For some reason all it spits out is:</p>
  
  <pre><code>There was 1 error:
  
  1) AccountControllerTest::testPostLoginNoEmailSpecified
  Cartalyst\Sentry\Users\LoginRequiredException: 
  </code></pre>
  
  <p>Am I using the andThrow() method incorrectly? If anyone can shed any light on what is going on it would be much appreciated.</p>
  
  <p>Thanks in advance!</p>