I followed all the steps. In the - Languages & Frameworks > PHP > Test Frameworks - I added Interpreter: Docker PHP 7. But under "Path to Script" I get message "PHPUnit Version: Not installed". On command line unit test works fine. And in PHPUNit Console I get this message - The value of autoloader is specified, but file doesn't exist '/opt/project/vendor/autoload.php' Any suggestion to fix this.
PHPStorm always does a "docker-compose up" even when the containers are already running. I have a container each for PHP and nginx; PHPStorm kills the PHP container, starts the PHP container and kills it again after PHPUnit has finished. The tests get executed okay, but now my manual test environment (i.e. using a browser) doesn't work because only the nginx container is running. Is there a neat way to avoid this? I suppose I could create a copy of the PHP container that is exclusively for PHPUnit but then I have two PHP containers to maintain and keep in sync. That is not ideal.
Currently, we don't have a way to reuse a container. Here's the feature request. However, I don't quite get what you mean by "PhpStorm kills the PHP container". Why would it? It just needs its own container, it doesn't care about already running containers.
Probably, this is happening to the fact that in the IDE settings for phpunit you specified the same docker-compote. Alternatively, specify another docker-compose, especially for this case, or continually restart the docker.
I would like to see this revisted with WordPress and PHPUnit tests as I have it connecting OK. Finding the root address from /app/wordpress to /opt/project/wordpress through me but now I cannot get the MySQL to connect so I can't run any tests
it's works, but in tests that have connection to database i got this error SQLSTATE[08006] [7] could not translate host name "postgres" to address: Name or service not known Note that everything goes fine on php execution, but in PHPUnit tests i got this message
Hi Mohamed, that means that the container you're using to run your tests can't get connection to your DB container. That may be because they're not in the same network, or even not running at the same time. Are you using a Docker Compose interpreter, or a plain Docker one?
This works for local mysql setup. However if mysql is inside a docker container - I can't make this setup to work. Getting `connected timed out` when connecting to remote mysql on test execution attempt. And I believe all the values are right - as my app itself is working and spent a decent amount of time debugging without luck...
Are containers running in the same docker network? Did you start MySQL container? You can also check solutions like intellij-support.jetbrains.com/hc/en-us/community/posts/115000099384-Run-tests-on-existing-docker-container or contact our support via intellij-support.jetbrains.com/hc/en-us/requests/new?ticket_form_id=66731 to get assistance.
It's possible natively, you just need to ensure that: 1) One container can access the other via network 2) MySQL is listening on all interfaces, not only 127.0.0.1, in the DB container
In our company we use Docker inside of Vagrant (using an Ubuntu image) because our developers have different operating systems. Is there also a solution to run PHPUnit in PhpStorm with our particular setup?
No, unfortunately, there's no separate video for Windows 10. But Native Docker for Windows installation is quite straightforward, did you stumble upon an issue?
Awesome, that is example how tutorials should be like - you follow and it works.
Should we keep the default value `/opt/project` even if our project is located in `/var/www/html`?
If so, why are we able to edit it?
I followed all the steps. In the - Languages & Frameworks > PHP > Test Frameworks - I added Interpreter: Docker PHP 7. But under "Path to Script" I get message "PHPUnit Version: Not installed". On command line unit test works fine. And in PHPUNit Console I get this message - The value of autoloader is specified, but file doesn't exist '/opt/project/vendor/autoload.php' Any suggestion to fix this.
same problem
Yes, thank you for this video!
PHPStorm always does a "docker-compose up" even when the containers are already running. I have a container each for PHP and nginx; PHPStorm kills the PHP container, starts the PHP container and kills it again after PHPUnit has finished. The tests get executed okay, but now my manual test environment (i.e. using a browser) doesn't work because only the nginx container is running. Is there a neat way to avoid this? I suppose I could create a copy of the PHP container that is exclusively for PHPUnit but then I have two PHP containers to maintain and keep in sync. That is not ideal.
Currently, we don't have a way to reuse a container. Here's the feature request.
However, I don't quite get what you mean by "PhpStorm kills the PHP container". Why would it? It just needs its own container, it doesn't care about already running containers.
Probably, this is happening to the fact that in the IDE settings for phpunit you specified the same docker-compote. Alternatively, specify another docker-compose, especially for this case, or continually restart the docker.
JetBrainsTV "Why would it?" Don't know, don't care - it simply kills the PHP Container and this suckz.
found this bug on youtrack youtrack.jetbrains.com/issue/WI-37986?_ga=2.96222111.245329677.1578905668-74880419.1548927938
thank you very much. It took 3 hours.
Awesome tutorial for the setup! Thanks for sharing.
Button of Run doesn't work. Beacause the directory of file is empty. It's doesn't work here with IntelliJ IDE 2019.3.4
I would like to see this revisted with WordPress and PHPUnit tests as I have it connecting OK. Finding the root address from /app/wordpress to /opt/project/wordpress through me but now I cannot get the MySQL to connect so I can't run any tests
it's works,
but in tests that have connection to database i got this error
SQLSTATE[08006] [7] could not translate host name "postgres" to address: Name or service not known
Note that everything goes fine on php execution, but in PHPUnit tests i got this message
Hi Mohamed, that means that the container you're using to run your tests can't get connection to your DB container.
That may be because they're not in the same network, or even not running at the same time.
Are you using a Docker Compose interpreter, or a plain Docker one?
@@JetBrainsTV I am getting the same error, I am using default Docker for Mac for Docker Compose interpreter
Great video, thanks!
This works for local mysql setup. However if mysql is inside a docker container - I can't make this setup to work. Getting `connected timed out` when connecting to remote mysql on test execution attempt. And I believe all the values are right - as my app itself is working and spent a decent amount of time debugging without luck...
Are containers running in the same docker network? Did you start MySQL container? You can also check solutions like intellij-support.jetbrains.com/hc/en-us/community/posts/115000099384-Run-tests-on-existing-docker-container or contact our support via intellij-support.jetbrains.com/hc/en-us/requests/new?ticket_form_id=66731 to get assistance.
you cannot access a database container inside a test, any idea how to fix this?
Павел, please clarify, are you trying to access the DB from a container or from the host machine?
from php container
It's possible natively, you just need to ensure that:
1) One container can access the other via network
2) MySQL is listening on all interfaces, not only 127.0.0.1, in the DB container
Thanks for tutorial, but how we can configure coverage and show coverage data in phpstorm?
@@spabby This is not working for me using Docker. Getting the Code Coverage locally using XDebug however works.
In our company we use Docker inside of Vagrant (using an Ubuntu image) because our developers have different operating systems. Is there also a solution to run PHPUnit in PhpStorm with our particular setup?
decline84 I would also be very interested in this kind of setup in conjunction with PhpStorm
Could you please vote for this issue in our issue tracker to bring it up for the development team youtrack.jetbrains.com/issue/WI-35515 Thanks!
Is there any Windows 10 + phpstorm + docker tut. video?
No, unfortunately, there's no separate video for Windows 10. But Native Docker for Windows installation is quite straightforward, did you stumble upon an issue?
I'll give a try, than i'll write.