Fix review feedback

This commit is contained in:
Arnaud Langlade
2018-03-13 11:45:25 +01:00
parent b1059a520c
commit 1a39d31f5e
4 changed files with 21 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ before_install:
install: install:
- composer require symfony/http-kernel:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - composer require symfony/http-kernel:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require symfony/dotenv:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require --dev symfony/framework-bundle:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - composer require --dev symfony/framework-bundle:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer update --prefer-dist - composer update --prefer-dist

View File

@@ -14,7 +14,7 @@
"behat/behat": "^3.1", "behat/behat": "^3.1",
"symfony/http-kernel": "^3.3|^4.0", "symfony/http-kernel": "^3.3|^4.0",
"symfony/dotenv": "^4.0" "symfony/dotenv": "^3.3|^4.0"
}, },
"require-dev": { "require-dev": {
"behat/mink": "^1.7", "behat/mink": "^1.7",

View File

@@ -67,6 +67,7 @@ Feature: Not crashing Behat
kernel: kernel:
path: src/MyKernel.php path: src/MyKernel.php
class: MyKernel class: MyKernel
bootstrap: ~
""" """
And a file ".env_in_memory" containing: And a file ".env_in_memory" containing:
""" """

View File

@@ -61,6 +61,16 @@ final class SymfonyExtension implements Extension
*/ */
const SHARED_KERNEL_CONTAINER_ID = 'sylius_symfony_extension.shared_kernel.container'; const SHARED_KERNEL_CONTAINER_ID = 'sylius_symfony_extension.shared_kernel.container';
/**
* Default symfony environment used to run your suites.
*/
private const DEFAULT_ENV = 'test';
/**
* Enable or disable the debug mode
*/
private const DEBUG_MODE = false;
/** /**
* @var CrossContainerProcessor|null * @var CrossContainerProcessor|null
*/ */
@@ -115,10 +125,11 @@ final class SymfonyExtension implements Extension
if (null !== $config['env_file']) { if (null !== $config['env_file']) {
$this->loadEnvVars($container, $config['env_file']); $this->loadEnvVars($container, $config['env_file']);
$environment = getenv('APP_ENV'); $environment = false !== getenv('APP_ENV') ? getenv('APP_ENV') : self::DEFAULT_ENV;
$config['kernel']['env'] = $environment ?? 'test'; $debugMode = false !== getenv('APP_DEBUG') ? getenv('APP_DEBUG') : self::DEBUG_MODE;
} else {
$this->requireKernelBootstrapFile($container->getParameter('paths.base'), $config['bootstrap']); $config['kernel']['env'] = $environment;
$config['kernel']['kernel'] = $debugMode;
} }
$this->loadKernel($container, $config['kernel']); $this->loadKernel($container, $config['kernel']);
@@ -142,7 +153,7 @@ final class SymfonyExtension implements Extension
/** /**
* @param ContainerBuilder $container * @param ContainerBuilder $container
* @param string $fileName * @param string $fileName
*/ */
private function loadEnvVars(ContainerBuilder $container, string $fileName): void private function loadEnvVars(ContainerBuilder $container, string $fileName): void
{ {
@@ -163,6 +174,8 @@ final class SymfonyExtension implements Extension
$definition->setFile($this->getKernelFile($container->getParameter('paths.base'), $config['path'])); $definition->setFile($this->getKernelFile($container->getParameter('paths.base'), $config['path']));
$container->setDefinition(self::KERNEL_ID, $definition); $container->setDefinition(self::KERNEL_ID, $definition);
$this->requireKernelBootstrapFile($container->getParameter('paths.base'), $config['bootstrap']);
} }
/** /**