0

I use PhpStorm in development. To run a test I do below 3 commands:

docker-compose exec app bash
cd app/
vendor/bin/phpunit unitTest/Sample.php 

I want to be able to run the test just by clicking the "Run" button inside PhpStorm.

I tried to accomplish it using docs from IntelliJ but they overwhelmed me. I thought I just need to change the interpreter path but couldn't understand how to attach to a running docker.

1 Answer 1

4

First you need to add your Docker-compose based interpreter. See this guide. php interpreter Second, add a PHPUnit configuration based on this interpreter, see "Integrate PHPUnit with a PhpStorm project". phpunit config After that you should be able to simply Run the tests using IDE UI.

Sign up to request clarification or add additional context in comments.

3 Comments

I will just add that, you don't have to use /opt/project but the path you see on top on the second image inside Path mappings. And the first image, you should click Connect to existing container ('docker-compose exec') instead of docker-compose run
I was able to run the tests. However it run the tests from different directory what gives me errors. How can implement the "cd app/" into the configuration?
Update: I was able to fix it by adding working_dir: /app to docker-compose

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.