From ee97cc5b00a7eb2051177cbaee1f69776e79dea7 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 2 May 2021 12:39:32 +0000 Subject: [PATCH] [TESTS] Add test container with Xdebug and allow for generation of coverage reports with 'make test' --- .env.test | 1 + .gitignore | 5 ++++- Makefile | 3 +++ docker/php/entrypoint.sh | 6 ++++++ docker/testing/Dockerfile | 8 ++++++++ docker/testing/coverage.sh | 7 +++++++ docker/testing/xdebug.ini | 3 +++ 7 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 docker/testing/Dockerfile create mode 100755 docker/testing/coverage.sh create mode 100644 docker/testing/xdebug.ini diff --git a/.env.test b/.env.test index d0486867ed..aca3bae320 100644 --- a/.env.test +++ b/.env.test @@ -3,3 +3,4 @@ KERNEL_CLASS='App\Kernel' APP_SECRET='$ecretf0rt3st' SYMFONY_DEPRECATIONS_HELPER=999999 PANTHER_APP_ENV=panther +DATABASE_URL=postgresql://postgres:password@db:5432/social diff --git a/.gitignore b/.gitignore index 675b2a63d7..8714630358 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,7 @@ social.local.yaml config.php /file -notes \ No newline at end of file +notes + + +.test_coverage_report \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..b25a3b0d71 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ + +test: + cd docker/testing && docker-compose run php diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh index 5f588fde63..24967bb76e 100755 --- a/docker/php/entrypoint.sh +++ b/docker/php/entrypoint.sh @@ -6,6 +6,12 @@ echo "Got response from DB" for script in /var/entrypoint.d/*.sh; do $script + ret=$? + if [ $ret -eq 64 ]; then + exit 0 + elif [ $ret -eq 65 ]; then + exit 1 + fi done exec php-fpm diff --git a/docker/testing/Dockerfile b/docker/testing/Dockerfile new file mode 100644 index 0000000000..0f51fd1119 --- /dev/null +++ b/docker/testing/Dockerfile @@ -0,0 +1,8 @@ +FROM gsocial/php + +WORKDIR /var/www/social + +RUN apk update \ + && apk add --no-cache $PHPIZE_DEPS \ + && pecl install xdebug \ + && docker-php-ext-enable xdebug diff --git a/docker/testing/coverage.sh b/docker/testing/coverage.sh new file mode 100755 index 0000000000..b9c7720d71 --- /dev/null +++ b/docker/testing/coverage.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if /var/www/social/bin/phpunit --coverage-html .test_coverage_report; then + exit 64 +else + exit 65 +fi diff --git a/docker/testing/xdebug.ini b/docker/testing/xdebug.ini new file mode 100644 index 0000000000..c8aed1f8a0 --- /dev/null +++ b/docker/testing/xdebug.ini @@ -0,0 +1,3 @@ +zend_extension=xdebug +xdebug.mode=develop,coverage +