title: Auth::attempt fails with PHPUnit TESTING
body: <p>I have a really strange behavior and I do not see where it could come from. I built an authentication system with Laravel documentation. When I save a User and try to login from the application, it works fine. However when I do the same thing in my AuthControllerTest, the Auth::attempt fails.</p>
  
  <p>AuthControllerTest.php</p>
  
  <pre><code>&lt;?php
  use tests\helpers\Factory;
  
  class AuthControllerTest extends ApiTester
  {
      use Factory;
  
      public function setUp()
      {
          parent::setUp();
         Artisan::call('migrate');
          Route::enableFilters();
          Session::start();
      }
  
  /*
  This test fails
  I have a 401 instead of a 200 HTTP response code
  */
      /** @test */
      public function it_should_log_in_user()
      {
          User::create([
              'email'          =&gt; 'testing@testing.com',
              'password'       =&gt; 'testing'
          ]);
  
          $credentials = [
              'email'    =&gt; 'testing@testing.com',
              'password' =&gt; 'testing'
          ];
      //dd(User::count() // I have 1 record
          $this-&gt;getJson('login', 'POST', $credentials);
  
          $this-&gt;assertResponseOk();
      }
  
      /** @test */
      public function it_should_throws_exception_if_login_fails()
      {
          User::create([
              'email'    =&gt; 'testing@testing.com',
              'password' =&gt; 'testing'
          ]);
          $this-&gt;getJson('login', 'POST', [
              'email'    =&gt; 'testing@testing.com',
              'password' =&gt; 'test'
          ]);
          $this-&gt;assertResponseStatus(401);
      }
  
      /** @test */
      public function it_should_log_out_user()
      {
          $user = User::create([
              'email'    =&gt; 'testing@testing.com',
              'password' =&gt; 'password'
          ]);
          $this-&gt;be($user);
  
          $this-&gt;getJson('logout', 'POST');
          $this-&gt;assertResponseStatus(204);
      }
  
      /**
       * Generate Alert mock
       * @return array
       */
      protected function getStub()
      {
          return [
          ];
      }
  }
  </code></pre>
  
  <p>AuthController.php</p>
  
  <pre><code>&lt;?php
  
  
  use Arato\Transformers\UserTransformer;
  use controllers\ApiController;
  
  class AuthController extends ApiController
  {
      protected $userTransformer;
  
      function __construct(UserTransformer $userTransformer)
      {
          $this-&gt;userTransformer = $userTransformer;
      }
  
      public function login()
      {
          $rules = [
              'email'    =&gt; ['required', 'email'],
              'password' =&gt; ['required', 'alphaNum']
          ];
  
          $validator = Validator::make(Input::all(), $rules);
          if ($validator-&gt;fails()) {
              return $this-&gt;respondUnauthorized();
          }
  
          $userData = [
              'email'    =&gt; Input::get('email'),
              'password' =&gt; Input::get('password')
          ];
  
          if (Auth::attempt($userData)) {
              return $this-&gt;respond([
                  'data' =&gt; $this-&gt;userTransformer-&gt;transform(Auth::user())
              ]);
          } else {
              return $this-&gt;respondUnauthorized();
          }
      }
  
      public function logout()
      {
          Auth::logout();
  
          return $this-&gt;respondNoContent();
      }
  }
  </code></pre>
  
  <p>Thank you</p>