I'm on 5.1 and not able to find a definite answer what's the best practice regarding an eco- and test-system to use a separate database for tests.
I've:
- a development machine for dev and running local tests
- an external service running by CI (only runs phpunit)
When I run tests locally, I don't want them to interfere with my dev database, thus I've created dedicated database for tests.
To overcome the limitation that I've only one .env
file, I've modified the phpunit.xml.dist
file to have different database credentials defined via <env name="..." value=".."/>
.
When I want to run the tests on a remote CI service, I again need different values for user/pass and database names. In that case I've a "template phpunit.xml" file in my repo which, during the initialization phase on the remote CI, I generate with their respective environment variables (which are different than the ones I use).
For all non-production related environments I need to keep three files in sync otherwise things will start to break:
.env
phpunit.xml.dist
phpunit.xml
template file generated on demand on remote CI system
I understand the benefits of the non-versioned .env
, but it gets a huge pain to always keep those things in sync.
Are there better ways to manage this?
Aucun commentaire:
Enregistrer un commentaire