Docker-compose with PHPUnit - can't run
Hi,
I would like to create some simple test environment for PHPUnit test.
I run PHPUnit test in single docker container - it works. But I would like to connect to database using docker-compose.
Here is my docker compose:
And this is my interpreter:
Here is config for Remote Interpreter:
When I click start with this PHPUnit config:
I've got only this information:
If I use single image (built from Dockerfile) everything works.
-------------------------------
I've done another test. I run docker-compose manually and click Play button with configuration above. On the console I can see that phpunittest container exited and another run with test (but still Instantiating tests spinner is spinning).
My expectations are run docker-compose with tests via Play button and see result in PHPStorm like single container.
Please sign in to leave a comment.
Same problem here, hope you find a solution. If you have the Docker extension installed you should be able to see the log output if you open the container in the tab but it’s slow and I have issues with the container being stopped after the test(s) run (and loose the output).
I've done like this: https://xtreamwayz.com/blog/2017-12-03-phpstorm-phpunit-docker-compose-windows but still doesn't work :(
@Lampelk
I've chcecked stopped container in terminal and I can See, that all tests passed.
So the problem with PHPStorm is that doesn't attach to container to get results.
So to run tests I have to do this manually from terminal.
Please configure the PHPUnit service to be `depends_on` the DB container, otherwise the latter one won't be started when you run tests.
Also, please note that PhpStorm does not run tests in existing containers, when you run something with a Docker (or Docker Compose) interpreter, it starts a new one.
So, basically, when you click Run, PhpStorm tries to start a new PHPUnit container, and that kills the running service in favor of the new one.
is there a way to change the default behavior and force it to use an existing container? Would it be against the docker philosophy?
Unfortunately there's no option to do that currently: https://youtrack.jetbrains.com/issue/WI-37986