|
| 1 | +<?php |
| 2 | + |
| 3 | + |
| 4 | +namespace Symfony\Component\DependencyInjection\Tests\Compiler; |
| 5 | + |
| 6 | +use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass; |
| 7 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 8 | +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; |
| 9 | + |
| 10 | +class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase |
| 11 | +{ |
| 12 | + public function testExpressionLanguageProviderForwarding() |
| 13 | + { |
| 14 | + if (true !== class_exists('Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage')) { |
| 15 | + $this->markTestSkipped('The ExpressionLanguage component isn\'t available!'); |
| 16 | + } |
| 17 | + |
| 18 | + $tmpProviders = array(); |
| 19 | + |
| 20 | + $extension = $this->getMock('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface'); |
| 21 | + $extension->expects($this->any()) |
| 22 | + ->method('getXsdValidationBasePath') |
| 23 | + ->will($this->returnValue(false)); |
| 24 | + $extension->expects($this->any()) |
| 25 | + ->method('getNamespace') |
| 26 | + ->will($this->returnValue('http://example.org/schema/dic/foo')); |
| 27 | + $extension->expects($this->any()) |
| 28 | + ->method('getAlias') |
| 29 | + ->will($this->returnValue('foo')); |
| 30 | + $extension->expects($this->once()) |
| 31 | + ->method('load') |
| 32 | + ->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { |
| 33 | + $tmpProviders = $container->getExpressionLanguageProviders(); |
| 34 | + })); |
| 35 | + |
| 36 | + $provider = $this->getMock('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface'); |
| 37 | + $container = new ContainerBuilder(new ParameterBag()); |
| 38 | + $container->registerExtension($extension); |
| 39 | + $container->prependExtensionConfig('foo', array('bar' => true )); |
| 40 | + $container->addExpressionLanguageProvider($provider); |
| 41 | + |
| 42 | + $pass = new MergeExtensionConfigurationPass(); |
| 43 | + $pass->process($container); |
| 44 | + |
| 45 | + $this->assertEquals(array($provider), $tmpProviders); |
| 46 | + } |
| 47 | +} |
0 commit comments