title: Laravel unit testing calling a Route from a Test with authentication
body: <p>I'm testing my api. Before calling a route I log in user to application.
  Problem is that after authentication user's id is not assigned to <code>Auth::id()</code> within route call.</p>
  
  <p>Here is the scenario:</p>
  
  <p><strong>Test method:</strong></p>
  
  <pre><code>public function testApiGetOrder()
  {
      var_dump($this-&gt;user);  // first dump
      Auth::login($this-&gt;user); // Can't use $this-&gt;be($this-&gt;user) here, it would not help anyway...
      var_dump(Auth::id());  // second dump
  
      $response = $this-&gt;call('GET', '/order/' . $this-&gt;order-&gt;getKey());
  
      $this-&gt;assertResponseOk();
      $this-&gt;assertJson($response-&gt;getContent());
      $this-&gt;assertJsonStringEqualsJsonString($this-&gt;order-&gt;toJson(), $response-&gt;getContent());
  }
  </code></pre>
  
  <p><strong>OrderController's method:</strong></p>
  
  <pre><code>public function show($id)
  {
      var_dump(Auth::id());  // third dump
      var_dump(Auth::user()-&gt;getKey());   // fourth dump
  
      // Calling model's logic here
  }
  </code></pre>
  
  <p><strong><em>Output of of testApiGetOrder:</em></strong></p>
  
  <p>First dump:  <code>object(User)</code><br>
  Second dump: <code>int(1)</code><br>
  Third dump:  <code>NULL</code><br>
  Fourth dump: <code>int(1)</code>  </p>
  
  <p>Why the value of user's id is not assigned to <code>Auth::id()</code> ?</p>