phpunit.el icon indicating copy to clipboard operation
phpunit.el copied to clipboard

Support for running phpunit inside of a docker container

Open tonyampomah opened this issue 5 years ago • 3 comments

It is not possible to run phpunit inside of docker container. Would it be possible to allow support for this. To at least, allow to change the path to the phpunit bin path

tonyampomah avatar May 13 '20 10:05 tonyampomah

I had no issues with this .dir-locals.el file placed at the root of my project.

((php-mode . ((phpunit-args . ("exec" "php" "bin/phpunit"))
              (phpunit-executable . "docker-compose"))))

adapt to your needs.

jlagneau avatar Oct 24 '20 07:10 jlagneau

Here's how I made it work, with a docker-compose.yml file not in the root of the project, with it's .env file also not in the root of the project.

Generally, I have all my docker config stuff in a directory called docker_config in the root of my project.

((php-mode . ((phpunit-args . ("-f" "docker_config/docker-compose.yml" "--project-directory" "docker_config" "exec" "php-fpm" "vendor/bin/phpunit"))
            (phpunit-executable . "docker-compose"))))

javoscript avatar Nov 23 '20 20:11 javoscript

there's also a phpunit-root-directory variable that might come in handy in case you're using a docker-compose.override.yml - this way you wouldn't have to list configuration files and/or --project-directory explicitly in phpunit-args:

((php-mode . ((phpunit-root-directory . "~/my-project/docker-config")
              (phpunit-executable . "docker-compose")
              (phpunit-args . ("run" "--rm" "php" "vendor/bin/phpunit")))))

br3athein avatar Aug 25 '21 12:08 br3athein