Вы можете использовать это в своей функции настройки
protected $client;
protected $em;
/**
* PHP UNIT SETUP FOR MEMORY USAGE
* @SuppressWarnings(PHPMD.UnusedLocalVariable) crawler set instance for test.
*/
public function setUp()
{
$this->client = static::createClient(array(
'environment' => 'test',
),
array(
'HTTP_HOST' => 'host.tst',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0',
));
static::$kernel = static::createKernel();
static::$kernel->boot();
$this->em = static::$kernel->getContainer()
->get('doctrine')
->getManager();
$crawler = $this->client->followRedirects();
}
Не забудьте установить функцию отключения
protected function tearDown()
{
$this->em->close();
unset($this->client, $this->em,);
}