[Symfony CLI] Document about APP_ENV=test
behavior
#15228
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi 👋
I'm miigrating some projects to the Symfony CLI and Docker and I made a mistake by creating two Docker containers for the main database and a test database (one database per container), but the test database was not used when running
symfony php bin/phpunit
(I have tests which need a database).This is my
.docker-compose.yaml
:my
.env
file:and my
.env.test
file:I had to run PHPunit with
APP_ENV=test
to let Symfony CLI injectsDATABASE_TEST_URL
but it still didn't work because the database wastest_test
.It seems by luck I discovered an undocumented behaviour, running the Symfony CLI with
APP_ENV=test
updatesDATABASE_*
environment variables for a test environment, so we just need one database container and noDATABASE_URL
tricks.symfony var:export --multiline
outputs:APP_ENV=test symfony var:export --multiline
outputs:I think it can be intersting to document this behaviour, this way:
WDYT? Thanks!