8000 Add support to environment variables APP_ENV/DEBUG in KernelTestCase · symfony/symfony@4e58195 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e58195

Browse files
committed
Add support to environment variables APP_ENV/DEBUG in KernelTestCase
1 parent ade060e commit 4e58195

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,27 @@ protected static function createKernel(array $options = array())
188188
static::$class = static::getKernelClass();
189189
}
190190

191-
return new static::$class(
192-
isset($options['environment']) ? $options['environment'] : 'test',
193-
isset($options['debug']) ? $options['debug'] : true
194-
);
191+
if (isset($options['environment'])) {
192+
$env = $options['environment'];
193+
} elseif (isset($_SERVER['APP_ENV'])) {
194+
$env = $_SERVER['APP_ENV'];
195+
} elseif (isset($_ENV['APP_ENV'])) {
196+
$env = $_ENV['APP_ENV'];
197+
} else {
198+
$env = 'test';
199+
}
200+
201+
if (isset($options['debug'])) {
202+
$debug = $options['debug'];
203+
} elseif (isset($_SERVER['APP_DEBUG'])) {
204+
$debug = $_SERVER['APP_DEBUG'];
205+
} elseif (isset($_ENV['APP_DEBUG'])) {
206+
$debug = $_ENV['APP_DEBUG'];
207+
} else {
208+
$debug = true;
209+
}
210+
211+
return new static::$class($env, $debug);
195212
}
196213

197214
/**

0 commit comments

Comments
 (0)
0