diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index b588ed1aa2..998a4e0d65 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -45,6 +45,9 @@ class ContainerBuilder extends Container implements TaggedContainerInterface parent::__construct($parameterBag); $this->compiler = new Compiler(); + foreach ($this->compiler->getPassConfig()->getPasses() as $pass) { + $this->addObjectResource($pass); + } } /** @@ -150,6 +153,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface public function addCompilerPass(CompilerPassInterface $pass) { $this->compiler->addPass($pass); + + $this->addObjectResource($pass); } /** diff --git a/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php b/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php index 67c4dc503c..74f2cdfba6 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php @@ -410,7 +410,13 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $container = new ContainerBuilder(); $container->addResource($a = new FileResource(__DIR__.'/Fixtures/xml/services1.xml')); $container->addResource($b = new FileResource(__DIR__.'/Fixtures/xml/services2.xml')); - $this->assertEquals(array($a, $b), $container->getResources(), '->getResources() returns an array of resources read for the current configuration'); + $resources = array(); + foreach ($container->getResources() as $resource) { + if (false === strpos($resource, '.php')) { + $resources[] = $resource; + } + } + $this->assertEquals(array($a, $b), $resources, '->getResources() returns an array of resources read for the current configuration'); } /**