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
Cannot change Lavarel environment variables after first call #4062
Comments
Before a test runs the Laravel application object is initialized, and this also is the application object that is used for the first request in a test. However, to support multiple requests in a single test the application object is also re-initialized on each next request. You can see the relevant source code here: https://github.com/Codeception/Codeception/blob/2.2/src/Codeception/Lib/Connector/Laravel5.php#L109 This means that the application object is reset during the second To work around this problem you should create a separate test for each request. |
First of all thanks for your quick answer. |
Not right now. But you are not the first one with a similar issue, so I'll probably implement something that can help in these types of situations. Currently I am thinking of a hook that will be called after the application object is initialized, either via an event or by registering closures. But I'll have to investigate that a bit to see if this will not create any new problems. So I cannot say when something like this will be implemented. |
Thanks a lot. |
I created a solution for this issue, please review #4068 and provide feedback :) |
Thanks. |
Ok, great! |
Hi!
Could you please help me to solve my problem. I write API and use Codeception to test it.
In some cases, I need to send 2 or more calls to API but before that, I should change Lavarel environment variables(LEV). When I try to set it at first all is OK and inside my code(at the controller) I have the value of LEV the same as I set up. But after the first call(doesn't important method(get, post, ...)) the value of it takes on a default value. Below the part of code from the test:
As a result of the second query, I get
'data' => [
0 => null
]
null -is the default value for this LEV
But I expected - 15
What do I make wrong?
Thanks in advance
The text was updated successfully, but these errors were encountered: