500 status code for symfony functional test
<p>I'm performing a test just to see if a certain route is working. The page/route is found at <a href="http://localhost/login" rel="nofollow">http://localhost/login</a> and when I go there in the browser it works fine and I've tested this with no cookies and my cache cleared.</p>

<p>However, as soon as I test it in the phpunit <code>LoginControllerTest</code> class I recieve a 500 status code internal server error.</p>

<pre><code>&lt;?php

namespace Tests\AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class LoginControllerTest extends WebTestCase
{
    public function testLoginPage()
    {
        $client = static::createClient();

        $crawler = $client-&gt;request('GET', '/login'); 
        // var_dump($client-&gt;getRequest()-&gt;getContent()); // Is empty
        // 200 =&gt; 'OK'
        $this-&gt;assertEquals(200, $client-&gt;getResponse()-&gt;getStatusCode());
    }
    // ...
</code></pre>

<p>And so running <code>phpunit</code> fails with:</p>

<pre><code>Failed asserting that 500 matches expected 200.
</code></pre>

<hr>

<p>Here is the <code>security.yml</code> in case that is of any use in understanding the problem.</p>

<pre><code># app/config/security.yml
security:
    providers:
        db_provider:
            entity:
                class: AppBundle:Users
                property: Username

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]

    firewalls:
        secured_area:
            pattern: ^/
            anonymous: ~   

        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        default:
            pattern: ^/manage
            guard:
                authenticators:
                    - app.token_authenticator

    access_control:
        - { path: ^/manage, roles: ROLE_USER }
</code></pre>

<p>The route is defined and working (as expected).</p>

<pre><code>// ...
class LoginController extends Controller
{
    /**
     * @Route("/login", name="LoginForm")
     */
    public function loginFormAction(Request $request)
    {
    // ...
</code></pre>