|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Nyholm\BundleTest\Tests\Functional; |
| 4 | + |
| 5 | +use Nyholm\BundleTest\BaseBundleTestCase; |
| 6 | +use Nyholm\BundleTest\Tests\Fixtures\ConfigurationBundle\ConfigurationBundle; |
| 7 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 8 | + |
| 9 | +/** |
| 10 | + * @author Laurent VOULLEMIER <[email protected]> |
| 11 | + */ |
| 12 | +final class BundleConfigurationTest extends BaseBundleTestCase |
| 13 | +{ |
| 14 | + protected function getBundleClass() |
| 15 | + { |
| 16 | + return ConfigurationBundle::class; |
| 17 | + } |
| 18 | + |
| 19 | + public function provideBundleWithDifferentConfigurationFormats() |
| 20 | + { |
| 21 | + return [ |
| 22 | + [__DIR__.'/../Fixtures/Resources/ConfigurationBundle/config.yml'], |
| 23 | + [__DIR__.'/../Fixtures/Resources/ConfigurationBundle/config.xml'], |
| 24 | + [__DIR__.'/../Fixtures/Resources/ConfigurationBundle/config.php'], |
| 25 | + [function (ContainerBuilder $container) { |
| 26 | + $container->loadFromExtension('configuration', [ |
| 27 | + 'foo' => 'val1', |
| 28 | + 'bar' => ['val2', 'val3'], |
| 29 | + ]); |
| 30 | + }], |
| 31 | + ]; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @dataProvider provideBundleWithDifferentConfigurationFormats |
| 36 | + * |
| 37 | + * @param string|callable $config |
| 38 | + */ |
| 39 | + public function testBundleWithDifferentConfigurationFormats($config) |
| 40 | + { |
| 41 | + $kernel = $this->createKernel(); |
| 42 | + $kernel->addConfigFile($config); |
| 43 | + $this->bootKernel(); |
| 44 | + $this->assertEquals('val1', $kernel->getContainer()->getParameter('app.foo')); |
| 45 | + $this->assertEquals(['val2', 'val3'], $kernel->getContainer()->getParameter('app.bar')); |
| 46 | + } |
| 47 | +} |
0 commit comments