diff --git a/features/configuration/loading_kernel_based_on_configurtion.feature b/features/configuration/loading_kernel_based_on_configurtion.feature index 219c74f..8efc077 100644 --- a/features/configuration/loading_kernel_based_on_configurtion.feature +++ b/features/configuration/loading_kernel_based_on_configurtion.feature @@ -95,3 +95,52 @@ Feature: Loading kernel based on configuration """ When I run Behat Then it should pass + + Scenario: Loading kernel from custom path + Given a Behat configuration containing: + """ + default: + extensions: + FriendsOfBehat\SymfonyExtension: + kernel: + path: app/Nested/Kernel.php + class: AppKernel + """ + And a kernel file "app/Nested/Kernel.php" containing: + """ + loadFromExtension('framework', [ + 'test' => $this->getEnvironment() === 'test', + 'secret' => 'Pigeon', + ]); + + $loader->load(__DIR__ . '/../../config/services.yaml'); + } + + protected function configureRoutes(RouteCollectionBuilder $routes): void {} + } + """ + When I run Behat + Then it should pass diff --git a/src/ServiceContainer/SymfonyExtension.php b/src/ServiceContainer/SymfonyExtension.php index 60ab56b..bc6140b 100644 --- a/src/ServiceContainer/SymfonyExtension.php +++ b/src/ServiceContainer/SymfonyExtension.php @@ -55,7 +55,8 @@ final class SymfonyExtension implements Extension ->arrayNode('kernel') ->addDefaultsIfNotSet() ->children() - ->scalarNode('class')->end() + ->scalarNode('path')->defaultNull()->end() + ->scalarNode('class')->isRequired()->end() ->end() ->end() ->end() @@ -103,6 +104,10 @@ final class SymfonyExtension implements Extension $definition->addMethodCall('boot'); $definition->setPublic(true); + if ($config['path'] !== null) { + $definition->setFile($config['path']); + } + $container->setDefinition(self::KERNEL_ID, $definition); }