diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ea652382..ae228866 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -60,7 +60,11 @@ jobs:
grep -r -l "$string" tests/ | xargs sed -i "s/$string//g"
- name: PHPUnit
- run: composer exec phpunit -- --configuration phpunit.ci.xml --coverage-xml ./.coverage
+ run: |
+ case ${{ matrix.php }} in
+ 8.1|8.2|8.3 ) composer exec phpunit -- --configuration phpunit.ci.8.xml --coverage-xml ./.coverage;;
+ *) composer exec phpunit -- --configuration phpunit.ci.xml --coverage-xml ./.coverage;;
+ esac
env:
XDEBUG_MODE: coverage
diff --git a/.gitignore b/.gitignore
index dd74e98b..ee982aca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@ phpunit.xml
.phpunit.cache/
composer.lock
.DS_Store
-.env
\ No newline at end of file
+.env
+.coverage/
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 12545aa0..8796849a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,6 +3,7 @@ ARG COMPOSER_VERSION
FROM composer:${COMPOSER_VERSION} as composer
FROM php:${PHP_VERSION}-fpm
+ARG PHP_VERSION
ENV DEBIAN_FRONTEND noninteractive
@@ -16,6 +17,11 @@ RUN apt update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
+RUN case ${PHP_VERSION} in \
+ 8.0|8.1|8.2|8.3 ) pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug;; \
+ *) pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug;; \
+ esac
+
RUN usermod -u 1000 www-data
RUN groupmod -g 1000 www-data
diff --git a/Dockerfile.legacy b/Dockerfile.legacy
index 4223fa91..1692a16f 100644
--- a/Dockerfile.legacy
+++ b/Dockerfile.legacy
@@ -20,6 +20,10 @@ RUN apt update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
+# Install xdebug for code coverage
+RUN pecl install xdebug-2.5.5 \
+&& docker-php-ext-enable xdebug
+
RUN usermod -u 1000 www-data
RUN groupmod -g 1000 www-data
diff --git a/Taskfile.php.yml b/Taskfile.php.yml
index 9c03f34f..65fc9160 100644
--- a/Taskfile.php.yml
+++ b/Taskfile.php.yml
@@ -27,9 +27,9 @@ tasks:
cmds:
- >-
{{ if eq .PHP_VERSION "5.6" "7.0" }}
- docker compose run {{ .COMPOSE_SERVICE }} ./tests/legacy_tests.sh
+ docker compose run --rm {{ .COMPOSE_SERVICE }} ./tests/legacy_tests.sh
{{ else }}
- docker compose run {{ .COMPOSE_SERVICE }} composer exec phpunit --verbose -- --configuration phpunit.dist.xml --testsuite "Alma PHP Client Unit Test Suite"
+ docker compose run --rm {{ .COMPOSE_SERVICE }} composer exec phpunit --verbose -- --configuration {{ .PHPUNIT_FILE }} --testsuite "Alma PHP Client Unit Test Suite" --coverage-xml ./.coverage
{{ end }}
tests:integration:
@@ -39,9 +39,9 @@ tasks:
cmds:
- >-
{{ if eq .PHP_VERSION "5.6" "7.0" }}
- docker compose run {{ .COMPOSE_SERVICE }} ./tests/legacy_integration_tests.sh
+ docker compose run --rm {{ .COMPOSE_SERVICE }} ./tests/legacy_integration_tests.sh
{{ else }}
- docker compose run {{ .COMPOSE_SERVICE }} composer exec phpunit --verbose -- --configuration phpunit.dist.xml --testsuite "Alma PHP Client Integration Test Suite"
+ docker compose run --rm {{ .COMPOSE_SERVICE }} composer exec phpunit --verbose -- --configuration {{ .PHPUNIT_FILE }} --testsuite "Alma PHP Client Integration Test Suite"
{{ end }}
shell:
@@ -49,5 +49,5 @@ tasks:
deps:
- docker:build
cmds:
- - sed 's/{MYVERSION}/{{ .PHPUNIT_VERSION }}/g' phpunit.dist.xml > phpunit.xml
- - docker compose run {{ .COMPOSE_SERVICE }} bash
+ - sed 's/{MYVERSION}/{{ .PHPUNIT_VERSION }}/g' {{ .PHPUNIT_FILE }} > phpunit.xml
+ - docker compose run --rm {{ .COMPOSE_SERVICE }} bash
diff --git a/Taskfile.yml b/Taskfile.yml
index 74ede9f8..2e09d806 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -44,14 +44,17 @@ includes:
taskfile: Taskfile.php.yml
vars:
PHP_VERSION: "8.1"
+ PHPUNIT_FILE: phpunit.dist.8.xml
"8.2":
taskfile: Taskfile.php.yml
vars:
PHP_VERSION: "8.2"
+ PHPUNIT_FILE: phpunit.dist.8.xml
"8.3":
taskfile: Taskfile.php.yml
vars:
PHP_VERSION: "8.3"
+ PHPUNIT_FILE: phpunit.dist.8.xml
tasks:
default:
diff --git a/compose.yml b/compose.yml
index b73909d7..7c3bd0c7 100644
--- a/compose.yml
+++ b/compose.yml
@@ -12,6 +12,8 @@ services:
volumes:
- ./:/app
- /app/vendor
+ environment:
+ XDEBUG_MODE: coverage
php-legacy:
user: ${UID:-1000}:${GID:-1000}
diff --git a/phpunit.ci.8.xml b/phpunit.ci.8.xml
new file mode 100644
index 00000000..851e6fb7
--- /dev/null
+++ b/phpunit.ci.8.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ tests/Unit
+
+
+
+
+
+
+
+
+
diff --git a/phpunit.dist.8.xml b/phpunit.dist.8.xml
new file mode 100644
index 00000000..550e8793
--- /dev/null
+++ b/phpunit.dist.8.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+ tests/Unit
+
+
+ tests/Integration
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/phpunit.dist.xml b/phpunit.dist.xml
index 72837d2a..e3ff90a3 100644
--- a/phpunit.dist.xml
+++ b/phpunit.dist.xml
@@ -1,5 +1,10 @@
-
+
tests/Unit
@@ -8,6 +13,11 @@
tests/Integration
+
+
+ ./src/*
+
+
diff --git a/tests/legacy_tests.sh b/tests/legacy_tests.sh
index b21daaf9..a3eca141 100755
--- a/tests/legacy_tests.sh
+++ b/tests/legacy_tests.sh
@@ -11,4 +11,4 @@ string=': void'
grep -r -l "$string" tests/ | xargs sed -i "s/$string//g"
# Run tests
-composer exec phpunit --verbose -- --configuration phpunit.dist.xml --testsuite "Alma PHP Client Unit Test Suite"
+composer exec phpunit --verbose -- --configuration phpunit.dist.xml --testsuite "Alma PHP Client Unit Test Suite" --coverage-xml ./.coverage