X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FCompiler%2FMergeExtensionConfigurationPassTest.php;fp=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FCompiler%2FMergeExtensionConfigurationPassTest.php;h=b35521d206204f24e1485fa0a00c0fb6aa13a824;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/symfony/dependency-injection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/vendor/symfony/dependency-injection/Tests/Compiler/MergeExtensionConfigurationPassTest.php new file mode 100644 index 000000000..b35521d20 --- /dev/null +++ b/vendor/symfony/dependency-injection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Compiler; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; + +class MergeExtensionConfigurationPassTest extends TestCase +{ + public function testExpressionLanguageProviderForwarding() + { + $tmpProviders = array(); + + $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); + $extension->expects($this->any()) + ->method('getXsdValidationBasePath') + ->will($this->returnValue(false)); + $extension->expects($this->any()) + ->method('getNamespace') + ->will($this->returnValue('http://example.org/schema/dic/foo')); + $extension->expects($this->any()) + ->method('getAlias') + ->will($this->returnValue('foo')); + $extension->expects($this->once()) + ->method('load') + ->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { + $tmpProviders = $container->getExpressionLanguageProviders(); + })); + + $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock(); + $container = new ContainerBuilder(new ParameterBag()); + $container->registerExtension($extension); + $container->prependExtensionConfig('foo', array('bar' => true)); + $container->addExpressionLanguageProvider($provider); + + $pass = new MergeExtensionConfigurationPass(); + $pass->process($container); + + $this->assertEquals(array($provider), $tmpProviders); + } + + public function testExtensionConfigurationIsTrackedByDefault() + { + $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\Extension')->getMock(); + $extension->expects($this->once()) + ->method('getConfiguration') + ->will($this->returnValue(new FooConfiguration())); + $extension->expects($this->any()) + ->method('getAlias') + ->will($this->returnValue('foo')); + + $container = new ContainerBuilder(new ParameterBag()); + $container->registerExtension($extension); + $container->prependExtensionConfig('foo', array('bar' => true)); + + $pass = new MergeExtensionConfigurationPass(); + $pass->process($container); + + $this->assertContains(new FileResource(__FILE__), $container->getResources(), '', false, false); + } +} + +class FooConfiguration implements ConfigurationInterface +{ + public function getConfigTreeBuilder() + { + return new TreeBuilder(); + } +}