diff --git a/features/configuration/autodiscovering_application_kernel.feature b/features/configuration/autodiscovering_application_kernel.feature index 30cb9eb..43df648 100644 --- a/features/configuration/autodiscovering_application_kernel.feature +++ b/features/configuration/autodiscovering_application_kernel.feature @@ -78,7 +78,7 @@ Feature: Autodiscovering the application kernel protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $container->loadFromExtension('framework', [ - 'test' => $this->getEnvironment() === 'test', + 'test' => true, 'secret' => 'Pigeon', ]); @@ -118,7 +118,7 @@ Feature: Autodiscovering the application kernel protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $container->loadFromExtension('framework', [ - 'test' => $this->getEnvironment() === 'test', + 'test' => true, 'secret' => 'Pigeon', ]); @@ -164,7 +164,7 @@ Feature: Autodiscovering the application kernel protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $container->loadFromExtension('framework', [ - 'test' => $this->getEnvironment() === 'test', + 'test' => true, 'secret' => 'Pigeon', ]); @@ -200,7 +200,7 @@ Feature: Autodiscovering the application kernel protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $container->loadFromExtension('framework', [ - 'test' => $this->getEnvironment() === 'test', + 'test' => true, 'secret' => 'Pigeon', ]); diff --git a/features/configuration/configuring_application_kernel.feature b/features/configuration/configuring_application_kernel.feature index fea4bc1..a6d23e5 100644 --- a/features/configuration/configuring_application_kernel.feature +++ b/features/configuration/configuring_application_kernel.feature @@ -57,3 +57,21 @@ Feature: Configuring application kernel """ When I run Behat Then it should pass + + Scenario: Using configured environment + Given a Behat configuration containing: + """ + default: + extensions: + FriendsOfBehat\SymfonyExtension: + kernel: + environment: custom + """ + And a feature file containing: + """ + Feature: + Scenario: + Then the application kernel should have environment "custom" + """ + When I run Behat + Then it should pass diff --git a/features/configuration/loading_configured_application_kernel.feature b/features/configuration/loading_configured_application_kernel.feature index 69f0e02..67e6908 100644 --- a/features/configuration/loading_configured_application_kernel.feature +++ b/features/configuration/loading_configured_application_kernel.feature @@ -83,7 +83,7 @@ Feature: Loading configured application kernel protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $container->loadFromExtension('framework', [ - 'test' => $this->getEnvironment() === 'test', + 'test' => true, 'secret' => 'Pigeon', ]); @@ -132,7 +132,7 @@ Feature: Loading configured application kernel protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $container->loadFromExtension('framework', [ - 'test' => $this->getEnvironment() === 'test', + 'test' => true, 'secret' => 'Pigeon', ]); diff --git a/src/ServiceContainer/SymfonyExtension.php b/src/ServiceContainer/SymfonyExtension.php index b96a5bb..2d7777f 100644 --- a/src/ServiceContainer/SymfonyExtension.php +++ b/src/ServiceContainer/SymfonyExtension.php @@ -57,6 +57,7 @@ final class SymfonyExtension implements Extension ->children() ->scalarNode('path')->defaultNull()->end() ->scalarNode('class')->defaultNull()->end() + ->scalarNode('environment')->defaultValue('test')->end() ->end() ->end() ->end() @@ -98,7 +99,7 @@ final class SymfonyExtension implements Extension private function loadKernel(ContainerBuilder $container, array $config): void { $definition = new Definition($config['class'], [ - 'test', + $config['environment'], true, ]); $definition->addMethodCall('boot');