I am trying to set a database environment to test my Doctrine ORM Entity classes, without changing my real database.
I followed Symfony's documentation, but when I run php bin/console doctrine:fixtures:load
I get the warning:
Careful, database "graph" will be purged. Do you want to continue? (yes/no) [no]:
This is despite the fact that I have set an environment variable in my .env.test
file:
DATABASE_URL=mysql://testUser:testPassword@127.0.0.1/graph_test
Edit: here is the entire .env.test
file:
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
# Database test
DATABASE_URL=mysql://testUser:testPassword@127.0.0.1/graph_test
I tried to change my test/bootstrap.php
file but I get the same warning.
Is there a way to tell doctrine to take the DATABASE_URL
value from the .env.test
file? Any help will be appreciated.
PS There is no need for more than one test .env file.
If you use php bin/console doctrine:fixtures:load --env=test
you will only affect your test database.