added a way to retrieve the profiler from a test
This commit is contained in:
parent
f4d82f385e
commit
3b4efe52cb
|
@ -22,6 +22,8 @@ use Symfony\Components\HttpKernel\Test\WebTestCase as BaseWebTestCase;
|
|||
*/
|
||||
abstract class WebTestCase extends BaseWebTestCase
|
||||
{
|
||||
protected $kernel;
|
||||
|
||||
/**
|
||||
* Creates a Client.
|
||||
*
|
||||
|
@ -32,10 +34,10 @@ abstract class WebTestCase extends BaseWebTestCase
|
|||
*/
|
||||
public function createClient(array $options = array(), array $server = array())
|
||||
{
|
||||
$kernel = $this->createKernel($options);
|
||||
$kernel->boot();
|
||||
$this->kernel = $this->createKernel($options);
|
||||
$this->kernel->boot();
|
||||
|
||||
$client = $kernel->getContainer()->getTest_ClientService();
|
||||
$client = $this->kernel->getContainer()->getTest_ClientService();
|
||||
$client->setServerParameters($server);
|
||||
|
||||
$this->setCurrentClient($client);
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Symfony\Framework\WebBundle\Test;
|
|||
|
||||
use Symfony\Foundation\Test\WebTestCase as BaseWebTestCase;
|
||||
use Symfony\Components\Finder\Finder;
|
||||
use Symfony\Components\HttpKernel\Response;
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
|
@ -23,6 +24,15 @@ use Symfony\Components\Finder\Finder;
|
|||
*/
|
||||
abstract class WebTestCase extends BaseWebTestCase
|
||||
{
|
||||
public function getProfiler(Response $response)
|
||||
{
|
||||
$container = $this->kernel->getContainer();
|
||||
|
||||
if ($container->hasService('profiler')) {
|
||||
return $container->getProfilerService()->load($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Kernel.
|
||||
*
|
||||
|
|
Reference in New Issue