Search code examples
symfony4functional-testingsymfony-panther

How to make Symfony / Panther use the test-environment in tests?


When performing functional tests with the Panther-Client, the webserver that is started in the background does not use the "test" environment. Instead it seems to use the parameters provided in the .env file (currently points to the "dev" environment) and therefore I can not use a test-database for my functional tests.

Technically I can understand that this happens, as the php-webserver that is started doesn't know anything about the test-environment the test-client uses and only sees the .env-file.

Is there any option that I overlooked that can tell the php-webserver to start in the test-environment or has anybody found another solution for this problem?

(The same problem seems to exist with selenium-tests, but also there I did not find a solution.)


Solution

  • Thank you for pointing me into this direction. From there I found the pull-request that was responsibe for the change:

    https://github.com/symfony/recipes/pull/481

    and the documentation to update an existing project

    https://symfony.com/doc/current/configuration/dot-env-changes.html

    Once I updated my project accordingly, the webserver that was started from pather now uses the test-environment.
    I have to figure out how exactly they tell the webserver that starts in a separate process that it shall use the test environment - but for the time being, it works as intended. :-)