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

test and dev environment variables with docker-compose #381

Closed
grambas opened this issue Feb 17, 2023 · 1 comment
Closed

test and dev environment variables with docker-compose #381

grambas opened this issue Feb 17, 2023 · 1 comment

Comments

@grambas
Copy link

grambas commented Feb 17, 2023

we can use docker compose environment element to define symfony envs. For example DATABASE_URL.

services:
  php:
    environment:
      DATABASE_URL:  "mysql..."

Using this method all .env files, even .env.test.local file will be overwritten. In that case my tests runs on DATABASE_URL which is defined in docker-compose what is wrong, becouse test env has another database connection. My question is if it is possible to define symfony envs with docker-compsose for both dev and test environment

@maxhelias
Copy link
Collaborator

Your DATABASE_URL for your tests can be defined in the phpunit.xml file.

Otherwise you have to define your APP_ENV=test in the phpunit.xml and use a bootstrap file to load your configuration with something like this : (new Dotenv())->bootEnv(dirname(__DIR__)'/.env');.

As mentioned in #379, we need to rework this.

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