CGriffin
CGriffin

Reputation: 1476

Strange 'Empty test suite'. output when running PHPUnit Tests in Docker

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.

Upvotes: 1

Views: 238

Answers (1)

CGriffin
CGriffin

Reputation: 1476

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.

Upvotes: 2

Related Questions