title: Symfony2 functional test authentication
body: <p>I'm trying to set my functional tests up and I'm having problems with getting authenticated. I've read over this guide: <a href="http://symfony.com/doc/current/cookbook/testing/http_authentication.html" rel="noreferrer">http://symfony.com/doc/current/cookbook/testing/http_authentication.html</a> and implemented what they have said to do but I still get stuck on redirecting login. I'm sure this is something trivial but I'm not sure what. </p>
  
  <p><strong>Test Controller</strong></p>
  
  <pre><code>namespace HvH\ClientsBundle\Tests\Controller;
  
  use HvH\ClientsBundle\Controller\ClientsController;
  
  use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\HeaderBag;
  use Symfony\Component\HttpFoundation\Session;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  
  class ClientsControllerTest extends WebTestCase
  {
  
      public function testGetClientsAction()
      {
  
          $client = static::createClient();
  
          $client-&gt;request(
             '/clients/123456', 
             'GET', 
              array(), /* request params */ 
              array(), /* files */
              array('X-Requested-With' =&gt; "XMLHttpRequest", 'PHP_AUTH_USER' =&gt; 'testuser', 'PHP_AUTH_PW' =&gt; 'testpass')
          );
  
          print_r($client-&gt;getResponse());
          die();
      }
  }
  </code></pre>
  
  <p><strong>congif_test.yml</strong></p>
  
  <pre><code>security:
      firewalls:
          secured_area:
              http_basic:
  </code></pre>
  
  <p><strong>Result of the request</strong></p>
  
  <pre><code>Symfony\Component\HttpFoundation\RedirectResponse Object
  (
      [headers] =&gt; Symfony\Component\HttpFoundation\ResponseHeaderBag Object
          (
              [computedCacheControl:protected] =&gt; Array
                  (
                      [no-cache] =&gt; 1
                  )
  
              [cookies:protected] =&gt; Array
                  (
                      [] =&gt; Array
                          (
                              [/] =&gt; Array
                                  (
                                      [PHPSESSID] =&gt; Symfony\Component\HttpFoundation\Cookie Object
                                          (
                                              [name:protected] =&gt; PHPSESSID
                                              [value:protected] =&gt; 7e3ece541918264de0003e2dcd251833
                                              [domain:protected] =&gt; 
                                              [expire:protected] =&gt; 1342616045
                                              [path:protected] =&gt; /
                                              [secure:protected] =&gt; 
                                              [httpOnly:protected] =&gt; 
                                          )
  
                                  )
  
                          )
  
                  )
  
              [headers:protected] =&gt; Array
                  (
                      [location] =&gt; Array
                          (
                              [0] =&gt; http://localhost/login
                          )
  
                      [cache-control] =&gt; Array
                          (
                              [0] =&gt; no-cache
                          )
  
                      [date] =&gt; Array
                          (
                              [0] =&gt; Wed, 18 Jul 2012 00:54:05 GMT
                          )
  
                      [content-type] =&gt; Array
                          (
                              [0] =&gt; text/html
                          )
  
                      [x-debug-token] =&gt; Array
                          (
                              [0] =&gt; 5006092d43848
                          )
  
                  )
  
              [cacheControl:protected] =&gt; Array
                  (
                  )
  
          )
  
      [content:protected] =&gt; &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
          &lt;meta http-equiv="refresh" content="1;url=http://localhost/login" /&gt;
  
          &lt;title&gt;Redirecting to http://localhost/login&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          Redirecting to &lt;a href="http://localhost/login"&gt;http://localhost/login&lt;/a&gt;.
      &lt;/body&gt;
  &lt;/html&gt;
      [version:protected] =&gt; 1.0
      [statusCode:protected] =&gt; 302
      [statusText:protected] =&gt; Found
      [charset:protected] =&gt; UTF-8
  )
  </code></pre>
  
  <p>Any suggestions on how to get around this?</p>