title: Laravel: PHPUnit causing 404s for everything
body: <p>I'm trying to run some basic unit tests for my Laravel application with PHPUnit.</p>
  
  <p>However, all HTTP requests return a 404 not found HTTP status code, so we are failing at the first hurdle.</p>
  
  <p>After trawling the internet, I have found information about how to remedy this, but so far none of these actually work:</p>
  
  <ul>
  <li>Checking I've referenced the named route correctly.</li>
  <li>Checking that this route has a controller method.</li>
  <li>Checking that it works in the browser.</li>
  <li>I've ensured that my application url is set correctly in all the right places: <code>TestCase::$baseUrl</code>, <code>Config-&gt;app-&gt;url</code>...Its set to <code>http://localhost/myappfolder</code></li>
  <li>I've tried different methods from within my unit test methods to get an HTTP response object. So far all result in a 404: <code>$this-&gt;route()</code>, <code>$this-&gt;action()</code>, <code>$this-&gt;call()</code>.</li>
  <li>I've tried removing all references to route protection Middleware from my controllers. I believe that it is disabled when running unit tests, but I've done this as I'm pulling my proverbial hair out trying to diagnose this problem. No effect.</li>
  <li>My application's roots file has several PHP <code>require</code>s that includes smaller route files. Taylor Otwell has said previously that a routes file like this, but containing <code>require_once</code> can cause these 404 errors. He suggests changing to <code>require</code>. Some developers report that this fixes it for them, but mine have just been <code>require</code> all along. I have also tried moving routes back into the main routes file anyway, but this has not worked either.</li>
  </ul>
  
  <p>Investigations have been usually unusual:</p>
  
  <ul>
  <li>If I edit the <code>route()</code> method within <code>Illuminate\Foundation\Testing\Concerns</code> to print out the URL it generates, it is in fact perfectly formed: <code>http://localhost/myprojectfolder/route-url-text</code>. Visiting this page in the browser works fine. Visiting it with cURL works too. Running <code>$this-&gt;call()</code> on the URL thats been generated, and then running PHPUnit shows the 404 again. So its just PHPUnit doing something weird.</li>
  </ul>
  
  <p>Here is the code I'm using in the unit test script:</p>
  
  <pre><code>public function testThis()
  {
      $response = $this-&gt;route('GET', 'myRouteName', [
          'myParam' =&gt; 5
      ]);
      dd($response-&gt;status()); // 404 - always!
  }
  </code></pre>
  
  <p>Its like there is something stepping in and explicitly throwing a 404...Would really appreciate if someone could shed light on this.</p>