Running PHPUnit Tests in PhpStorm with Docker
Why Stack Overflow recommends it
Stack Overflow users link it as the official step-by-step walkthrough for configuring PhpStorm to run PHPUnit tests inside Docker, usually as the setup they followed before hitting a problem.
Recommended by 1 people across 1 different months, 2017 to 2022.
What it is
A short JetBrains tutorial in which PhpStorm Developer Advocate Gary Hockin shows how to run PHPUnit tests in PhpStorm using a Docker container. It walks through configuring a Docker instance, setting up a PHP interpreter from a container, and pointing PHPUnit at it. It is part of a series that also covers local and Vagrant setups.
What people said
Recommends Pavel Shorokhov · 2017-12 · Stack Overflow · on “Run PHPUnit in a Docker container and start containers it depends on”
The answer is too long. I hope this 5 minutes video by Jetbrains TV helps you. [this video] In short you need: Configure Docker instance in PHPStorm Configure new PHP Interpreter from Docker container Configure PHPUnit to use your new interpreter
Cites Michael Millar · 2018-02 · Stack Overflow · on “How do I set up PhpStorm so that the Docker Compose Interpreter can use the PHP executable?”
I'm trying to integrate Docker with PhpStorm by following this JetBrainsTV video [this video] . (The container is working fine - it's up and running). At the CLI Interpreter edit screen, it says PHP is not installed. [LINK] When I click the synchronise button, I get an 'Address in use' error. [LINK]
Cites Bounce · 2018-03 · Stack Overflow · on “PhpStorm: running PHPUnit database tests from Docker container”
I configured PhpStorm to run PHPUnit tests from Docker container. Unfortunately if test tries to connect to MySQL server I get an error: SQLSTATE[HY000] [2002] Connection refused MySQL server runs in the same container. If I try to connect to MySQL server from container via some standalone script - it works fine. Also the app itself works fine too. Other tests (without database usage) work fine. Any ideas what is wrong with my PhpStorm configuration? I followed official step by step configuration video tutorial [this video] , but it does not cover database part. PhpStorm runs command that is being executed every time I hit run tests button: docker://mycontainer/myapp:v1.0/php /opt/.phpstorm_helpe
Cites Kostya · 2022-07 · Stack Overflow · on “How to run tests from Docker in PhpStorm?”
I configured PhpStorm for running tests from docker container in the IDE by clicking the Run button, but I got the following error when I run them: Doctrine\DBAL\Exception\ConnectionException : An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known from .env: database_host: sp_mysql database_port: null docker-compose: version: "3.4" services: nginx: container_name: sp_nginx image: nginx ports: - 8080:80 volumes: - ./docker/nginx/conf:/etc/nginx/conf.d/:ro - ./var/log/nginx/:/var/log/nginx:cached - ./web:/app/web depends_on: - php networks: - internal php: container_name: sp_php image: sp/php build: context: ./ dockerfil
Cites Zeth · 2022-10 · Stack Overflow · on “PhpStorm: Cannot parse PHPUnit version output: Could not open file: /var/www/docroot/vendor/phpunit/phpunit/phpunit”
I'm trying to setup PHPUnit in PhpStorm, so I can run tests from inside my IDE. I have Docker setup in PhpStorm, and I can see my containers in the 'Services'-tab and exec stuff in them, from inside PhpStorm. And if I click Update button (the circular arrows) next to 'Path to script', then it throws the error: Cannot parse PHPUnit version output: Could not open file: /var/www/docroot/vendor/phpunit/phpunit/phpunit It can be seen here: [LINK] The overarching question What is failing here? I'm guessing that PhpStorm is trying to access PHPUnit inside the Docker-container, but can't find that phpunit -file (from the error). ... Oh, yeah - and how do I fix it? :-) Quick solution attempts and tho