[SecurityBundle] Optimize dependency injection tests
This commit is contained in:
parent
9a90cde4ed
commit
bf56d2fc17
@ -19,6 +19,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
|
|
||||||
abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
private static $containerCache = array();
|
||||||
|
|
||||||
abstract protected function loadFromFile(ContainerBuilder $container, $file);
|
abstract protected function loadFromFile(ContainerBuilder $container, $file);
|
||||||
|
|
||||||
public function testRolesHierarchy()
|
public function testRolesHierarchy()
|
||||||
@ -182,6 +184,9 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getContainer($file)
|
protected function getContainer($file)
|
||||||
{
|
{
|
||||||
|
if (isset(self::$containerCache[$file])) {
|
||||||
|
return self::$containerCache[$file];
|
||||||
|
}
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$security = new SecurityExtension();
|
$security = new SecurityExtension();
|
||||||
$container->registerExtension($security);
|
$container->registerExtension($security);
|
||||||
@ -194,6 +199,6 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||||
$container->compile();
|
$container->compile();
|
||||||
|
|
||||||
return $container;
|
return self::$containerCache[$file] = $container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user