Skip to content

Commit 3f4c47c

Browse files
bug #24177 [FrameworkBundle] Add support to environment variables APP_ENV/DEBUG in KernelTestCase (yceruto)
This PR was merged into the 3.3 branch. Discussion ---------- [FrameworkBundle] Add support to environment variables APP_ENV/DEBUG in KernelTestCase | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/recipes#170 (comment) | License | MIT | Doc PR | - /cc @fabpot Commits ------- 8d56744 Add support to environment variables APP_ENV/DEBUG in KernelTestCase
2 parents 56bf807 + 8d56744 commit 3f4c47c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,27 @@ protected static function createKernel(array $options = array())
178178
static::$class = static::getKernelClass();
179179
}
180180

181-
return new static::$class(
182-
isset($options['environment']) ? $options['environment'] : 'test',
183-
isset($options['debug']) ? $options['debug'] : true
184-
);
181+
if (isset($options['environment'])) {
182+
$env = $options['environment'];
183+
} elseif (isset($_SERVER['APP_ENV'])) {
184+
$env = $_SERVER['APP_ENV'];
185+
} elseif (isset($_ENV['APP_ENV'])) {
186+
$env = $_ENV['APP_ENV'];
187+
} else {
188+
$env = 'test';
189+
}
190+
191+
if (isset($options['debug'])) {
192+
$debug = $options['debug'];
193+
} elseif (isset($_SERVER['APP_DEBUG'])) {
194+
$debug = $_SERVER['APP_DEBUG'];
195+
} elseif (isset($_ENV['APP_DEBUG'])) {
196+
$debug = $_ENV['APP_DEBUG'];
197+
} else {
198+
$debug = true;
199+
}
200+
201+
return new static::$class($env, $debug);
185202
}
186203

187204
/**

0 commit comments

Comments
 (0)