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.

6 comments

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).

0

@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.

0

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.

0

is there a way to change the default behavior and force it to use an existing container? Would it be against the docker philosophy?

0

Please sign in to leave a comment.