-
Notifications
You must be signed in to change notification settings - Fork 25
Symfony: environment: 'prod'
not working
#88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm this problem but coming at it from another direction. Regardless of the environment I specify, only the main .env file is loaded.
So to make things work, I have .env pointed to my test database and rely on .env.test and .env.dev to work correctly in the regular symfony app. I've tracked the code to my-app/src/Kernel.php where the correct env value is passed in, but .env files are read in the wrong order. |
In the course of further research, I discovered that the .env files seem to have the desired affect over the environment value specified in the symfony configuration above. So I'm not setting environment in the Codeception > Symfony module. In its place, using .env files seems to work well enough for both the main symfony stack AND codeception
|
@ThomasLandauer Can you reproduce this problem in the test project? I need to know if this is still a problem with the supported versions of Symfony, at least Codeception 4 and version 1.6 of this module. I am not able to reproduce or fix the problem with the versions described in this issue, so please update it. |
Yes, the issue is still there. I created https://github.com/ThomasLandauer/symfony-module-tests/tree/issue_88 |
This issue will be fixed with version 3.4.0 of the module. # tests/Functional.suite.yml
modules:
enabled:
- Symfony:
bootstrap: true Then you have to make sure that your You will have to have an After doing all this you will have to move the necessary settings in your I'm still not quite clear on the use case where you would want to run tests in this environment, but at least it's already possible to do so. |
What are you trying to achieve?
Run tests in Symfony's PROD environment.
What do you get instead?
Tests are still run in TEST environment.
Details
To investigate this, I created a controller which just outputs the environment (
return new Response($kernel->getEnvironment());
). When browsing to its url I get whatever I have in Symfony's.env
. Fine.When I access the url with codeception (
codecept_debug($I->grabPageSource());
), I get whatever I write intofunctional.suite.yml
, even an arbitrary string likefoo
.However, if I put
prod
, the app isn't really run in PROD environment. The feature I want to test is if the correct error page is shown. But in DEV/TEST environment Symfony always shows its internal Exception Page, not my own error page (see https://symfony.com/doc/current/controller/error_pages.html#testing-error-pages-during-development ) - that's how I know that I am still in TEST environment in fact.I even tried with a
@prepare
annotation ($symfony->_reconfigure(['environment' => 'prod']);
) to switch just for this single test (cause that's what I originally intended).The text was updated successfully, but these errors were encountered: