Authentication in functional tests in Symfony 2.1
问题 I am currently in the process of migrating a 2.0.* project to the current 2.1 beta of Symfony. In my functional tests i currently have this code to create a client with authentication: $client = // create a normal test client $role = 'ROLE_USER'; $firewallName = 'main'; $user = // pull a user from db $client->getCookieJar()->set(new \Symfony\Component\BrowserKit\Cookie(session_name(), true)); $token = new UsernamePasswordToken($user, null, $firewallName, array($role)); self::$kernel-