Answer the question
In order to leave comments, you need to log in
How to write test case-specific definitions to a container in API tests?
Hello.
I have a set of api tests for which I want to write specific definitions for a number of classes in a dependency injection container.
The problem is that I can only do this in the context of Unit tests, but I can’t do this in API tests, because. the changes will only apply to the current process running the test, while the test sends requests to the real application with the test config. Pushing test data for some specific test case will not work, only for all at once.
Who faced this problem? If yes, how did you decide?
Answer the question
In order to leave comments, you need to log in
Unfortunately, I did not solve such a problem, but perhaps the answer from the issue on github will do. If not, then you need to try dirty setting the environment settings for tests up to reflection in some setup/before method (if you figure out which parameters you need to change)
If I understand the question correctly (which I'm not sure about), then this is a deployment question.
Make a separate server on which you will deploy the project with an api-test environment, which at the time of initialization will slip yii init --env api-tests
another container config needed for these tests.
well, or do a dirty hack that I personally don't like, something like
if (isset($_GET['apitests']) && $_GET['apitests'] ==true && $_SERVER['HTTP_CLIENT_IP'] == '{IP ADDR}'){
return $devContainerConfig;
}
return $prodContainerConfig;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question