title: PHPUnit test in Symfony 5 - unit test always return a 404 or 500
body: <h2>Configuration :</h2>
  <p><strong>OS</strong> : MacOS Catalina 10.15.4 <br />
  <strong>Web server</strong> : Apache (using MAMP) <br />
  <strong>PHP version</strong> : 7.3.9 <br />
  <strong>Symfony version</strong> : Symfony CLI version v4.16.3 <br />
  <strong>Composer version</strong> : Composer version 1.10.7 <br/></p>
  <h1>Issue :</h1>
  <p>I started using PHPUnit as mentioned in the Symfony documentation about testing, and I wanted to try it with a simple test: send get request to my main page (route = '/') and see if I have a 200 status code as expected. <br/></p>
  <h1>My process :</h1>
  <p>In my project :</p>
  <pre class="lang-sh prettyprint-override"><code>composer req --dev Symfony/PHPUnit-bridge Symfony/css-selector symfony/browser-kit symfony/maker-bundle
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>bin/console make:functional-test MainControllerTest
  </code></pre>
  <p>and here is the test file in tests/ :</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  
  namespace App\Tests\Controller;
  use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  
  
  class MainControllerTest extends WebTestCase
  {
  
  
      public function testIndex()
      {
          $c = static::createClient();
          $c-&gt;request('GET','/');
          $this-&gt;assertEquals(200, $c-&gt;getResponse()-&gt;getStatusCode(), 'REQUEST IS : ' . $c-&gt;getRequest());
      }
  }
  </code></pre>
  <p>So this is the basic test controller, I just modified it a bit by customizing the output message to get my request as an output.</p>
  <p>then :</p>
  <pre class="lang-sh prettyprint-override"><code>bin/PHPUnit tests
  </code></pre>
  <p>and finally my output :</p>
  <pre class="lang-sh prettyprint-override"><code>PHPUnit 8.3.5 by Sebastian Bergmann and contributors.
  
  Runtime:       PHP 7.3.8 with Xdebug 2.7.2
  Configuration: /Applications/MAMP/htdocs/DEV/symfony_app/phpunit.xml
  
  Testing tests
  F                                                                   1 / 1 (100%)
  
  Time: 947 ms, Memory: 24.00 MB
  
  There was 1 failure:
  
  1) App\Tests\Controller\MainControllerTest::testIndex
  
  REQUEST IS : GET /DEV/symfony_app/public/index.php/dossier/all HTTP/1.1
  Accept:          text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Charset:  ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Accept-Language: en-us,en;q=0.5
  Host:            localhost:8888
  User-Agent:      Symfony BrowserKit
  X-Php-Ob-Level:  1
  
  
  Failed asserting that 404 matches expected 200.
  
  /Applications/MAMP/htdocs/DEV/symfony_app/tests/Controller/MainControllerTest.php:16
  
  FAILURES!
  Tests: 1, Assertions: 1, Failures: 1.
  </code></pre>
  <p>But my web server is running and I can access my '/' route, I've tried changing the Uri to 'http://localhost:8888/DEV/symfony_app/public/' or 'http://localhost:8888/DEV/symfony_app/public/index.php'
  <br>
  but it always returns 404 instead of 200.
  <br>
  I've configured some routes and main is one of them if you are not authenticated you are redirected to '/login' which is one of the only routes you can access as an anonymous user, so I tried to this test with my '/login' route but I also have 404 status.</p>
  <p>I'm literally at the beginning of the <a href="https://symfony.com/doc/current/testing.html" rel="nofollow noreferrer">testing documentation</a> but if this simple test doesn't work I can't go further.
  <br>
  Any clue on this?</p>
  <h2>Similar issues I saw :</h2>
  <p><a href="https://stackoverflow.com/questions/36326998/symfony-functional-test-fail-but-the-same-request-works-in-browser">Symfony functional test fail but the same request works in browser</a></p>
  <p><em>Unfortunately, none of the answers fixed my problem</em></p>