Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing default bootstrapping for "test" env #574

Closed
phansys opened this issue Apr 11, 2019 · 1 comment
Closed

Confusing default bootstrapping for "test" env #574

phansys opened this issue Apr 11, 2019 · 1 comment

Comments

@phansys
Copy link

phansys commented Apr 11, 2019

Given the changes made at #491, using config/bootstrap.php as bootstrap of phpunit is not possible if .env.local.php exists without variables that closely belongs to the "test" env ("KERNEL_CLASS", "SYMFONY_DEPRECATIONS_HELPER", etc); since the file from where these variables should be loaded (.env.test) isn't required at all:

KERNEL_CLASS='App\Kernel'
APP_SECRET='s$cretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999

Since these variables are not common for the local environment, the dumped array at .env.local.php doesn't contains them, making the test suite unusable without changes:

if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Apr 11, 2019

Yes, that's correct. We need to enhance documentation around this as it's quite new.
As you spotted, .env.local.php freezes .env files. As such and on purpose, it's only for prod-like needs. Don't use it in test nor dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants