Merge pull request #123 from ubermuda/feature/use-config-environment-for-app-env
This commit is contained in:
@@ -81,6 +81,7 @@ Feature: Configuring application kernel
|
|||||||
Feature:
|
Feature:
|
||||||
Scenario:
|
Scenario:
|
||||||
Then the application kernel should have environment "custom"
|
Then the application kernel should have environment "custom"
|
||||||
|
And the server and environment variable "APP_ENV" is "custom"
|
||||||
"""
|
"""
|
||||||
When I run Behat
|
When I run Behat
|
||||||
Then it should pass
|
Then it should pass
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ final class SymfonyExtension implements Extension
|
|||||||
|
|
||||||
public function load(ContainerBuilder $container, array $config): void
|
public function load(ContainerBuilder $container, array $config): void
|
||||||
{
|
{
|
||||||
$this->fallbackToTestEnvironment();
|
$this->setupTestEnvironment($config['kernel']['environment'] ?? 'test');
|
||||||
|
|
||||||
$this->loadBootstrap($this->autodiscoverBootstrap($config['bootstrap']));
|
$this->loadBootstrap($this->autodiscoverBootstrap($config['bootstrap']));
|
||||||
|
|
||||||
@@ -182,11 +182,11 @@ final class SymfonyExtension implements Extension
|
|||||||
require_once $bootstrap;
|
require_once $bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fallbackToTestEnvironment(): void
|
private function setupTestEnvironment(string $fallback): void
|
||||||
{
|
{
|
||||||
// If there's no defined server / environment variable with an environment, default to test
|
// If there's no defined server / environment variable with an environment, default to configured fallback
|
||||||
if (($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) === null) {
|
if (($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) === null) {
|
||||||
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'test');
|
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $fallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user