-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
WebTestCase always carries Parameters from previous test case #20024
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
Reading ENV params at runtime is one thing, but isn't there an easier solution in this case? Each test case is supposed to be clearing the cache entirely, everything is supposedly being rebuilt from the ground up between each test, so where is this cached config coming from? How can we be sure that similar problems won't prevail in this regard? If I am running a test case that builds my Symfony environment, loads parameters.yml, parameters.php, and I can see that it is doing so because I can Any ideas? |
Ok, now I understand the problem: |
Yeah, loading the container class is the main thing here. There's also few things wrong with your test cases:
I'm not sure what's your use case for changing parameters for each test case. If you need further support please use one of our supporte channels at http://symfony.com/support |
I agree the test2 has a few issues, because I was tinkering with it and forgot to change it back before pasting it here - individually I can get any one of the tests to run fine (if I fix test2) - but regardless, I will never have all 3 passing together. (Test3 does call The use case for testing the parameters change is because I need to demonstrate that the different configurations that the app can be deployed with will all work, for example, some configs can be used to switch on or off certain internal modules, or testing connections to different types of database, or maybe pointing my app at different third party URLs to interact with external APIs. There's a bunch of different scenarios I want to test, and these properties are configured through ENV vars, as the deployment of the application instances is via Docker, with the config options being passed through ENV. I will get in touch with the support channels if I need any assistance. In the meantime I'm going to investigate using |
See #20065 |
Uh oh!
There was an error while loading. Please reload this page.
Just recreated this on Symfony 3.1, also occurs on 2.7.
When a WebTestCase is run, any subsequent iterations of running that WebTestCase will have the same parameters set, even if the
parameters.php
config file is using different values from previous test cases.I have narrowed the problem as I see it, down to the instance of
appTestDebugProjectContainer.php
which has an old set of parameters, but I can't see where it's retrieved them from. I suspect a rogue static var being used somewhere, perhaps in a Reflection class or similar.Reproduction:
Create a new Symfony 3.1 project, and modify the following files:
app/config/config.yml
app/config/parameters.yml
append to the end of the fileapp/config/parameters.php
tests/AppBundle/EnvResetTest.php
The outcome varies depending on whether you enable the line
php bin/console cache:warmup --env=test
in the testsetUp
method, but only one of the tests will ever pass, regardless of this.Test1 passes if the line is disabled, Test2 passes if the line is enabled. The other tests will fail.
This proves the parameter values are carried from one execution to the next, despite proving that the parameters.php file being executed for each test.
It feels like this shouldn't happen, I haven't seen any documentation to suggest this behaviour should be expected... If there is a workaround I can use in the meantime, like for resetting some statically cached parameters somewhere, that would be very much appreciated.
This is the last hurdle to overcome in order for my webTestCase scripts to enable testing of my application in different configurations, from a single test suite.
The text was updated successfully, but these errors were encountered: