Open bastien70 opened 4 years ago
Same problem here.
The .env.test
has a test-specific DATABASE_URL
.
The test case retrieves an entityID from the database using the EntityManager
. It then uses that ID in a route to retrieve the web page with $client->request('GET', sprintf('/object/edit/%s', $id))
and it gets a 404 NOT FOUND.
When the DATABASE_URL
is removed from .env.test
so that tests are run against the database in .env
, then the above scenario works without any issues.
I found a work-around for this problem.
In .env.test
:
PANTHER_APP_ENV=panther
Then, in / create a new .env.panther
and include the same DATABASE_URL
that is in .env.test
.
BTW, having PANTHER_APP_ENV=test
in .env.test
does not work because then you get:
Cannot set session ID after the session has started. (500 Internal Server Error)
When you run phpunit - there is test environment in the test class, but when you call real browser from your test via $client->request()
- there could be another environment, for example "dev" - if in your .env
or .env.local
file APP_ENV is set to dev.
You can set APP_ENV=test
in your .env.local or create test.php front-controller based on index.php front-controller and set env inside test.php: $_SERVER['APP_ENV'] = 'test';
Same problem here.
I tried with
PANTHER_APP_ENV=panther
in my .ent.test
Then I created a new .env.panther file with database_url but it's not working.
I launched panther y headless mode with
PANTHER_NO_HEADLESS=1 PANTHER_DEVTOOLS=0 php bin/phpunit tests/UserTest.php
If I go to the profiler I can see that Panther uses dev environment and also that the database_url is the one from the dev file instead of the test db
Any help or clue how to fix this?
@metaer describes the issue well. We can't really use a test.php
, nor do we want to fiddle with .env.local
every time we run tests. We're using the following solution for the same issue with php-webdriver:
APP_ENV=test
to .env.test
(distributed with repo, we also set APP_DEBUG=0
)setUpBeforeClass
, we call exec('cd /path/to/project/root/ && /path/to/php /path/to/composer dump-env test', $output, $resultCode);
tearDownAfterClass
, we call exec('rm /path/to/project/root/.env.local.php', $output, $resultCode);
Works great for us.
I found a work-around for this problem.
In
.env.test
:PANTHER_APP_ENV=panther
Then, in / create a new
.env.panther
and include the sameDATABASE_URL
that is in.env.test
.BTW, having
PANTHER_APP_ENV=test
in.env.test
does not work because then you get:Cannot set session ID after the session has started. (500 Internal Server Error)
Thank you, PANTHER_APP_ENV=test
in .env.test
worked for me, maybe since 2020 there was some update related to this
I found a work-around for this problem. In
.env.test
:PANTHER_APP_ENV=panther
Then, in / create a new
.env.panther
and include the sameDATABASE_URL
that is in.env.test
. BTW, havingPANTHER_APP_ENV=test
in.env.test
does not work because then you get:Cannot set session ID after the session has started. (500 Internal Server Error)
Thank you,
PANTHER_APP_ENV=test
in.env.test
worked for me, maybe since 2020 there was some update related to this
Same problem and this worked for me as well
Hello, it looks like Panther does not launch with the test environment.
According to the doc ', we could put this in the .env.test file:
.env.test
When I restart Panther, the environment is indicated as the test environment. However, if I go to my login page to log users with Panther, if I enter credentials belonging to the dev environment, it will work, but not if I enter information from the test environment. .