1

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.)

Sqrt-1764
  • 321
  • 1
  • 17
  • Hey if you are using symfony 4.2 you can upgrade to the new way of defineing the .env : https://symfony.com/blog/new-in-symfony-4-2-define-env-vars-per-environment Hey, have you tried updaing symfony to use the new .env format ? Meaning the .env file doesn't contain any information and is just the template you then create a .env.local file with your local settings and a .env.test file with your test settings. This way when I run my panther tests the correct environment is used – Dennis de Best Feb 18 '19 at 15:47

2 Answers2

1

I was able to fix this problem by creating a specific Panther environment:

Add this line to .env.test:

PANTHER_APP_ENV=panther

Then create a file .env.panther and add your database settings to that file:

DATABASE_URL="mysql://user:password@mariadb:3306/test"
Boschman
  • 825
  • 1
  • 10
  • 17
0

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. :-)

Sqrt-1764
  • 321
  • 1
  • 17