Аутентификация функциональных тестов Symfony2

Я пытаюсь настроить свои функциональные тесты, и у меня возникают проблемы с прохождением аутентификации. Я прочитал это руководство:http://symfony.com/doc/current/cookbook/testing/http_authentication.htmlи реализовал то, что они сказали, но я все еще застреваю при перенаправлении входа в систему. Я уверен, что это что-то тривиальное, но я не уверен, что.

Контроллер испытаний

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->request(
           '/clients/123456', 
           'GET', 
            array(), /* request params */ 
            array(), /* files */
            array('X-Requested-With' => "XMLHttpRequest", 'PHP_AUTH_USER' => 'testuser', 'PHP_AUTH_PW' => 'testpass')
        );

        print_r($client->getResponse());
        die();
    }
}

config _test.yml

security:
    firewalls:
        secured_area:
            http_basic:

Результат запроса

Symfony\Component\HttpFoundation\RedirectResponse Object
(
    [headers] => Symfony\Component\HttpFoundation\ResponseHeaderBag Object
        (
            [computedCacheControl:protected] => Array
                (
                    [no-cache] => 1
                )

            [cookies:protected] => Array
                (
                    [] => Array
                        (
                            [/] => Array
                                (
                                    [PHPSESSID] => Symfony\Component\HttpFoundation\Cookie Object
                                        (
                                            [name:protected] => PHPSESSID
                                            [value:protected] => 7e3ece541918264de0003e2dcd251833
                                            [domain:protected] => 
                                            [expire:protected] => 1342616045
                                            [path:protected] => /
                                            [secure:protected] => 
                                            [httpOnly:protected] => 
                                        )

                                )

                        )

                )

            [headers:protected] => Array
                (
                    [location] => Array
                        (
                            [0] => http://localhost/login
                        )

                    [cache-control] => Array
                        (
                            [0] => no-cache
                        )

                    [date] => Array
                        (
                            [0] => Wed, 18 Jul 2012 00:54:05 GMT
                        )

                    [content-type] => Array
                        (
                            [0] => text/html
                        )

                    [x-debug-token] => Array
                        (
                            [0] => 5006092d43848
                        )

                )

            [cacheControl:protected] => Array
                (
                )

        )

    [content:protected] => 

    
        
        

        Redirecting to http://localhost/login
    
    
        Redirecting to http://localhost/login.
    

    [version:protected] => 1.0
    [statusCode:protected] => 302
    [statusText:protected] => Found
    [charset:protected] => UTF-8
)

Любые предложения о том, как обойти это?

7
задан greg 18 July 2012 в 00:58
поделиться