[FrameworkBundle] Optimize framework extension tests
This commit is contained in:
parent
7d72f93e90
commit
f6a078b96c
@ -18,6 +18,8 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
abstract class FrameworkExtensionTest extends TestCase
|
||||
{
|
||||
private static $containerCache = array();
|
||||
|
||||
abstract protected function loadFromFile(ContainerBuilder $container, $file);
|
||||
|
||||
public function testCsrfProtection()
|
||||
@ -307,6 +309,10 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
|
||||
protected function createContainerFromFile($file, $data = array())
|
||||
{
|
||||
$cacheKey = md5($file.serialize($data));
|
||||
if (isset(self::$containerCache[$cacheKey])) {
|
||||
return self::$containerCache[$cacheKey];
|
||||
}
|
||||
$container = $this->createContainer($data);
|
||||
$container->registerExtension(new FrameworkExtension());
|
||||
$this->loadFromFile($container, $file);
|
||||
@ -315,6 +321,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->compile();
|
||||
|
||||
return $container;
|
||||
return self::$containerCache[$cacheKey] = $container;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user