Running PHPUnit Tests in PhpStorm with Docker

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 32

  • @darius7313
    @darius7313 5 лет назад +2

    Awesome, that is example how tutorials should be like - you follow and it works.

  • @richardcarree2828
    @richardcarree2828 7 лет назад +5

    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?

  • @SunilSharma-mo1yz
    @SunilSharma-mo1yz 7 лет назад +5

    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.

    • @xzioooo
      @xzioooo 4 года назад

      same problem

  • @vtchkrcn
    @vtchkrcn 3 года назад +1

    Yes, thank you for this video!

  • @donconore
    @donconore 7 лет назад +4

    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.

    • @JetBrainsTV
      @JetBrainsTV  7 лет назад

      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.

    • @alexeybril6742
      @alexeybril6742 6 лет назад

      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.

    • @jan42
      @jan42 6 лет назад +1

      JetBrainsTV "Why would it?" Don't know, don't care - it simply kills the PHP Container and this suckz.

    • @MrDivan4ik
      @MrDivan4ik 4 года назад

      found this bug on youtrack youtrack.jetbrains.com/issue/WI-37986?_ga=2.96222111.245329677.1578905668-74880419.1548927938

  • @alongNinja
    @alongNinja 3 года назад

    thank you very much. It took 3 hours.

  • @eamirgh
    @eamirgh 5 лет назад

    Awesome tutorial for the setup! Thanks for sharing.

  • @rios0rios0
    @rios0rios0 4 года назад

    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

  • @MrWilde
    @MrWilde 6 лет назад

    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

  • @MohamedFathifat7i
    @MohamedFathifat7i 6 лет назад +2

    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

    • @JetBrainsTV
      @JetBrainsTV  6 лет назад

      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?

    • @arjunkishore
      @arjunkishore 4 года назад

      @@JetBrainsTV I am getting the same error, I am using default Docker for Mac for Docker Compose interpreter

  • @CaseyCS7
    @CaseyCS7 5 лет назад

    Great video, thanks!

  • @MrGoldbergification
    @MrGoldbergification 6 лет назад

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

    • @JetBrainsTV
      @JetBrainsTV  6 лет назад

      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.

  • @SupunPraneeth
    @SupunPraneeth 6 лет назад +1

    you cannot access a database container inside a test, any idea how to fix this?

    • @JetBrainsTV
      @JetBrainsTV  6 лет назад

      Павел, please clarify, are you trying to access the DB from a container or from the host machine?

    • @SupunPraneeth
      @SupunPraneeth 6 лет назад

      from php container

    • @JetBrainsTV
      @JetBrainsTV  6 лет назад

      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

  • @s0uldr3dd
    @s0uldr3dd 7 лет назад

    Thanks for tutorial, but how we can configure coverage and show coverage data in phpstorm?

    • @Baris1892
      @Baris1892 5 лет назад

      @@spabby This is not working for me using Docker. Getting the Code Coverage locally using XDebug however works.

  • @decline84
    @decline84 7 лет назад +1

    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?

    • @duneplanet
      @duneplanet 7 лет назад

      decline84 I would also be very interested in this kind of setup in conjunction with PhpStorm

    • @JetBrainsTV
      @JetBrainsTV  7 лет назад

      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!

  • @ElTebe
    @ElTebe 7 лет назад

    Is there any Windows 10 + phpstorm + docker tut. video?

    • @JetBrainsTV
      @JetBrainsTV  7 лет назад

      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?

    • @ElTebe
      @ElTebe 7 лет назад

      I'll give a try, than i'll write.