Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add support to environment variables APP_ENV/DEBUG in KernelTestCase
  • Loading branch information
yceruto committed Sep 12, 2017
commit 8d5674480f8b7dfbd908fbc5492ac3393074f2ee
25 changes: 21 additions & 4 deletions src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,27 @@ protected static function createKernel(array $options = array())
static::$class = static::getKernelClass();
}

return new static::$class(
isset($options['environment']) ? $options['environment'] : 'test',
isset($options['debug']) ? $options['debug'] : true
);
if (isset($options['environment'])) {
$env = $options['environment'];
} elseif (isset($_SERVER['APP_ENV'])) {
$env = $_SERVER['APP_ENV'];
} elseif (isset($_ENV['APP_ENV'])) {
$env = $_ENV['APP_ENV'];
} else {
$env = 'test';
}

if (isset($options['debug'])) {
$debug = $options['debug'];
} elseif (isset($_SERVER['APP_DEBUG'])) {
$debug = $_SERVER['APP_DEBUG'];
} elseif (isset($_ENV['APP_DEBUG'])) {
$debug = $_ENV['APP_DEBUG'];
} else {
$debug = true;
}

return new static::$class($env, $debug);
}

/**
Expand Down