I've set up a docker-compose environment with Redis, MySQL, php-fpm, and an Nginx webserver. Here's the relevant parts of docker-compose.yml:
webserver:
image: nginx:alpine
container_name: webserver
working_dir: /application
volumes:
- .:/application
- ./phpdocker/webserver/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8082:80"
php-fpm:
build: phpdocker/php-fpm
container_name: php-fpm
working_dir: /application
volumes:
- .:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini
And here's the structure of the referenced php-fpm build:
FROM phpdockerio/php73-fpm:latest
WORKDIR "/application"
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.3-mysql php-redis php-xdebug \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install git
RUN apt-get update \
&& apt-get -y install git \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
You may recognize the structure or defaults; I generated it with phpdocker.
My containers are all building nicely, so my next step was to be set up PHPStorm to run the tests from within the php-fpm Docker container. I got the remote interpreter and PHPUnit path set up correctly, ran a basic test, and get this (bizarre) output:
docker-compose://[/Users/christian/projects/application/docker-compose.yml]:php-fpm/php /application/src/app/vendor/bin/phpunit --configuration /application/phpunit.xml --filter "/(::testPagesReturnExpectedStatus)( .*)?$/" Tests\Smoke\SmokeTest /application/tests/php/Smoke/SmokeTest.php --teamcity
Starting application__phpstorm_helpers_1 ...
Recreating php-fpm ...
Attaching to php-fpm
php-fpm | PHPUnit 7.4.3 by Sebastian Bergmann and contributors.
php-fpm |
php-fpm | Runtime: PHP 7.3.6-1+ubuntu18.04.1+deb.sury.org+1 with Xdebug 2.7.1
php-fpm | Configuration: /application/phpunit.xml
php-fpm |
php-fpm |
php-fpm |
php-fpm | fivefour-php-fpm |
php-fpm | Empty test suite.
php-fpm |
php-fpm |
php-fpm | Time: 1.59 seconds, Memory: 6.00 MB
php-fpm |
php-fpm |
php-fpm | ERRORS!
php-fpm | Tests: 9, Assertions: 0, Errors: 1.
php-fpm exited with code 2
Aborting on container exit...
Process finished with exit code 2
There's two things I notice right away: normally, when there are errors in a test, PHPUnit will output those errors. Here, I get nothing. Secondly, I get a message that says 'Empty test suite.', despite the fact that a couple of lines down, it prints 'Tests: 9, Assertions: 0, Errors: 1`, which doesn't seem like an empty test suite to me.
In short, I've absolutely no idea what's going on or even how to troubleshoot it! If anyone has some insight, I would great appreciate it.
php /application/src/app/vendor/bin/phpunit blah-blah) manually withdocker-compose run(ordocker-compose exec, depending on how you configured your remote interpreter).--teamcityargument that PHPUnit adds. Finally, I can see my error! But, it doesn't seem practical to, whenever my tests fail, re-run the tests from the command line and remove that argument to see the error output.Empty test suitewarning still there without the--teamcityargument? From what I can see, errors still should be printed out even with the argument, so I suppose the issue is caused by something else: prntscr.com/o2tnnt