Fix complete config tests

This commit is contained in:
Julien Falque 2016-11-21 23:14:54 +01:00
parent 2af58be68f
commit b25c1d30f6
No known key found for this signature in database
GPG Key ID: 6B13BB4B40DBD0E9
4 changed files with 27 additions and 11 deletions

View File

@ -21,7 +21,9 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
{ {
private static $containerCache = array(); private static $containerCache = array();
abstract protected function loadFromFile(ContainerBuilder $container, $file); abstract protected function getLoader(ContainerBuilder $container);
abstract protected function getFileExtension();
public function testRolesHierarchy() public function testRolesHierarchy()
{ {
@ -237,6 +239,8 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
protected function getContainer($file) protected function getContainer($file)
{ {
$file = $file.'.'.$this->getFileExtension();
if (isset(self::$containerCache[$file])) { if (isset(self::$containerCache[$file])) {
return self::$containerCache[$file]; return self::$containerCache[$file];
} }
@ -246,7 +250,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
$bundle = new SecurityBundle(); $bundle = new SecurityBundle();
$bundle->build($container); // Attach all default factories $bundle->build($container); // Attach all default factories
$this->loadFromFile($container, $file); $this->getLoader($container)->load($file);
$container->getCompilerPassConfig()->setOptimizationPasses(array()); $container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array()); $container->getCompilerPassConfig()->setRemovingPasses(array());

View File

@ -17,9 +17,13 @@ use Symfony\Component\Config\FileLocator;
class PhpCompleteConfigurationTest extends CompleteConfigurationTest class PhpCompleteConfigurationTest extends CompleteConfigurationTest
{ {
protected function loadFromFile(ContainerBuilder $container, $file) protected function getLoader(ContainerBuilder $container)
{ {
$loadXml = new PhpFileLoader($container, new FileLocator(__DIR__.'/Fixtures/php')); return new PhpFileLoader($container, new FileLocator(__DIR__.'/Fixtures/php'));
$loadXml->load($file.'.php'); }
protected function getFileExtension()
{
return 'php';
} }
} }

View File

@ -17,9 +17,13 @@ use Symfony\Component\Config\FileLocator;
class XmlCompleteConfigurationTest extends CompleteConfigurationTest class XmlCompleteConfigurationTest extends CompleteConfigurationTest
{ {
protected function loadFromFile(ContainerBuilder $container, $file) protected function getLoader(ContainerBuilder $container)
{ {
$loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')); return new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml'));
$loadXml->load($file.'.xml'); }
protected function getFileExtension()
{
return 'xml';
} }
} }

View File

@ -17,9 +17,13 @@ use Symfony\Component\Config\FileLocator;
class YamlCompleteConfigurationTest extends CompleteConfigurationTest class YamlCompleteConfigurationTest extends CompleteConfigurationTest
{ {
protected function loadFromFile(ContainerBuilder $container, $file) protected function getLoader(ContainerBuilder $container)
{ {
$loadXml = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/yml')); return new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/yml'));
$loadXml->load($file.'.yml'); }
protected function getFileExtension()
{
return 'yml';
} }
} }