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 w
In my testsuite (working on 2.0 and now 2.1) I use a Base class WebTestCase that extends the Symfony2 WebTestCase class.
I have these two functions that create an anonymous client or a logged one in my tests:
static protected function createClient(array $options = array(), array $server = array())
{
$client = parent::createClient($options, $server);
self::$container = self::$kernel->getContainer();
return $client;
}
protected function createAuthClient($user, $pass)
{
return self::createClient(array(), array(
'PHP_AUTH_USER' => $user,
'PHP_AUTH_PW' => $pass,
));
}
Then, in my Test classes, I use:
$client = static::createClient();
to create an anon client and
$client = static::createAuthClient('user','pass');
to create an authenticated one.
This works like a charm on 2.1