Allow to configure the application kernel's custom environment
This commit is contained in:
@@ -78,7 +78,7 @@ Feature: Autodiscovering the application kernel
|
|||||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||||
{
|
{
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'test' => $this->getEnvironment() === 'test',
|
'test' => true,
|
||||||
'secret' => 'Pigeon',
|
'secret' => 'Pigeon',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ Feature: Autodiscovering the application kernel
|
|||||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||||
{
|
{
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'test' => $this->getEnvironment() === 'test',
|
'test' => true,
|
||||||
'secret' => 'Pigeon',
|
'secret' => 'Pigeon',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ Feature: Autodiscovering the application kernel
|
|||||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||||
{
|
{
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'test' => $this->getEnvironment() === 'test',
|
'test' => true,
|
||||||
'secret' => 'Pigeon',
|
'secret' => 'Pigeon',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ Feature: Autodiscovering the application kernel
|
|||||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||||
{
|
{
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'test' => $this->getEnvironment() === 'test',
|
'test' => true,
|
||||||
'secret' => 'Pigeon',
|
'secret' => 'Pigeon',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -57,3 +57,21 @@ Feature: Configuring application kernel
|
|||||||
"""
|
"""
|
||||||
When I run Behat
|
When I run Behat
|
||||||
Then it should pass
|
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
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ Feature: Loading configured application kernel
|
|||||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||||
{
|
{
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'test' => $this->getEnvironment() === 'test',
|
'test' => true,
|
||||||
'secret' => 'Pigeon',
|
'secret' => 'Pigeon',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ Feature: Loading configured application kernel
|
|||||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||||
{
|
{
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'test' => $this->getEnvironment() === 'test',
|
'test' => true,
|
||||||
'secret' => 'Pigeon',
|
'secret' => 'Pigeon',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ final class SymfonyExtension implements Extension
|
|||||||
->children()
|
->children()
|
||||||
->scalarNode('path')->defaultNull()->end()
|
->scalarNode('path')->defaultNull()->end()
|
||||||
->scalarNode('class')->defaultNull()->end()
|
->scalarNode('class')->defaultNull()->end()
|
||||||
|
->scalarNode('environment')->defaultValue('test')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
@@ -98,7 +99,7 @@ final class SymfonyExtension implements Extension
|
|||||||
private function loadKernel(ContainerBuilder $container, array $config): void
|
private function loadKernel(ContainerBuilder $container, array $config): void
|
||||||
{
|
{
|
||||||
$definition = new Definition($config['class'], [
|
$definition = new Definition($config['class'], [
|
||||||
'test',
|
$config['environment'],
|
||||||
true,
|
true,
|
||||||
]);
|
]);
|
||||||
$definition->addMethodCall('boot');
|
$definition->addMethodCall('boot');
|
||||||
|
|||||||
Reference in New Issue
Block a user