dmaicher / doctrine-test-bundle

Symfony bundle to isolate your app's doctrine database tests and improve the test performance
MIT License
1.08k stars 60 forks source link

Fix wrapping connection with dynamic parameters #189

Closed julienfalque closed 2 years ago

julienfalque commented 2 years ago

When a connection has parameters defined dynamically at runtime, the same wrapped connection is used because the cache key is only based on the connection's name, leading to using a connection that does not honor the parameters.

Always using a cache key based on all parameters (including connection's name) prevents this.

I faced this issue while running a PHPUnit test suite in which the database name is defined via an environment variable and changes depending on the tests. When running the entire suite, some tests failed because they connected to the wrong database (the one used for the first test that created a connection) while each test passed when run individually.