Skip to content

Commit 8b1bb78

Browse files
committed
Add support to environment variables APP_ENV/DEBUG in KernelTestCase
1 parent d56e1af commit 8b1bb78

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

Test/KernelTestCase.php

Lines changed: 21 additions & 4 deletions
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)