title: Cannot simulate authentication in Symfony functional test
body: <p>I followed the <a href="http://symfony.com/doc/current/cookbook/testing/http_authentication.html" rel="nofollow">instructions</a> in the cookbook to simulate HTTP authentication inside my functional tests.</p>
  
  <p>I added the following to my <strong>config_test.yml</strong>:</p>
  
  <pre><code>security:
      firewalls:
          main:
              http_basic:
                  realm: "Secured Demo Area"
  </code></pre>
  
  <p>And this is how my test looks like:</p>
  
  <pre><code>class CourseControllerTest extends WebTestCase
  {
      public function setUp()
      {
          $this-&gt;loadFixtures(array(
              'Herudio\Bundle\UserBundle\DataFixtures\ORM\LoadUserData',
              'Herudio\Bundle\CourseBundle\DataFixtures\ORM\LoadCategoryData',
              'Herudio\Bundle\CourseBundle\DataFixtures\ORM\LoadCourseData',
          ));
      }
  
      public function testListDisplaysAllEntities()
      {
          $client = static::createClient(array(), array(
              'PHP_AUTH_USER' =&gt; 'admin',
              'PHP_AUTH_PW'   =&gt; 'admin',
          ));
  
          $crawler = $client-&gt;request('GET', '/courses');
  
          $this-&gt;assertCount(1, $crawler-&gt;filter('tbody tr'), 'Unexpected entity count for GET /courses/');
      }
  }
  </code></pre>
  
  <p>However, when I run the test, I get redirected to <strong>/login</strong>.</p>
  
  <p>I already ensured that the User entity is created correctly.</p>
  
  <p>Note: I'm using FOSUserBundle for authentication.</p>