I have an integration test that fires a curl
request to an API URL with the hostname from a docker container. The API has a different docker-compose.yml than the PHP's docker-compose.yml, so they are configured to be linked over a shared network (see Communication between multiple docker-compose projects).
When I run the test over the terminal of PHP's container (php vendor/phpunit/phpunit/phpunit tests
), the API (that has the docker containers name as host name) from the other docker-compose environment, is reachable. So it is being resolved, and responds with content.
But when I run the test over PhpStorm, that uses the PHP interpreter from docker-compose, the API URL can't be resolved, as if would ignore the shared network. In the terminal I can see a long PHPUnit command is generated and fired from PhpStorm:
[docker://php_php:latest/]:php /opt/project/php/vendor/phpunit/phpunit/phpunit --no-configuration --filter MyNamespace\\Tests\\CurlTest --test-suffix CurlTest.php /opt/project/php/tests/Integration --teamcity --cache-result-file=/opt/project/.phpunit.result.cache
How can I fix the PhpStorm test runner to consider the shared network in Docker?