1

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.

4
  • The first thing to check here is if the output is any different when you run the same command (php /application/src/app/vendor/bin/phpunit blah-blah) manually with docker-compose run (or docker-compose exec, depending on how you configured your remote interpreter). Commented Jun 14, 2019 at 12:44
  • That's a good question. I tried the same command and got the same output, but on a hunch I removed that --teamcity argument 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. Commented Jun 14, 2019 at 13:36
  • Is the Empty test suite warning still there without the --teamcity argument? 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 Commented Jun 17, 2019 at 9:09
  • Empty test-suite in Phpunit means that no tests are found. That are either no test files (classes) at all or those found do not contain any test methods. Check all files are available inside the Docker container if you execute the files there. Phpstorm remote interpreter does temporarily move files there-in (or uses mapping), it is pretty limited, e.g. you can't see it working with non-project files, like scratch files. Commented Jul 1, 2019 at 0:31

1 Answer 1

2

I 'solved' this by setting up my docker image to allow SSH access, then using PHPStorm's SSH remote interpreter instead of the docker remote interpreter. I'm hesitant to accept my solution as the real answer, since it's more of a workaround, but I'll leave it here for posterity / future Googlers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.