From a9f3dc82aee08c088c1bb0848a06607d50930534 Mon Sep 17 00:00:00 2001 From: shahondin1624 Date: Wed, 22 Apr 2026 09:59:06 +0200 Subject: [PATCH] Add Makefile test target for running PHPUnit inside container Supports: make test # all suites (Unit, Integration, DatabasePortability) make test suite=Unit make test suite=Integration make test suite=DatabasePortability Also switches composer to install dev dependencies so PHPUnit is available. --- Makefile | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5c00bc0..be32851 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ .PHONY: build deps up down setup deploy redeploy logs clean package release \ up-postgres setup-postgres deploy-postgres clean-postgres \ - up-sqlite setup-sqlite deploy-sqlite clean-sqlite + up-sqlite setup-sqlite deploy-sqlite clean-sqlite \ + test # Install dependencies (composer via Docker since PHP may not be local) deps: npm install --no-audit --no-fund - docker run --rm -v "$$(pwd):/app" -w /app composer:2 install --no-dev --optimize-autoloader --no-interaction + docker run --rm -v "$$(pwd):/app" -w /app composer:2 install --optimize-autoloader --no-interaction # Build frontend build: deps @@ -202,6 +203,38 @@ deploy-sqlite: build up-sqlite setup-sqlite clean-sqlite: docker compose -f docker/sqlite/docker-compose.yml down -v +# Run all tests inside the Nextcloud container +# Supports: make test [suite=Unit] [suite=Integration] [suite=DatabasePortability] +test: + @if ! docker compose exec -T nextcloud test -f config/config.php 2>/dev/null; then \ + echo "ERROR: Nextcloud container is not running."; \ + echo " Start it with: make up && make setup"; \ + exit 1; \ + fi + @# Ensure app code is up to date inside the container + docker compose exec nextcloud cp -a /app-src/appinfo /var/www/html/custom_apps/mitgliederverwaltung/ + docker compose exec nextcloud cp -a /app-src/lib /var/www/html/custom_apps/mitgliederverwaltung/ + docker compose exec nextcloud cp -a /app-src/tests /var/www/html/custom_apps/mitgliederverwaltung/ + docker compose exec nextcloud cp -a /app-src/phpunit.xml /var/www/html/custom_apps/mitgliederverwaltung/ + docker compose exec nextcloud chown -R www-data:www-data /var/www/html/custom_apps/mitgliederverwaltung + @# Copy composer vendor dir with dev deps into app for PHPUnit + docker compose exec nextcloud cp -a /app-src/vendor /var/www/html/custom_apps/mitgliederverwaltung/ + @# Determine which test suite to run (default: all) + @if [ "$(suite)" = "" ]; then \ + echo "Running all tests..."; \ + docker compose exec -u www-data -T nextcloud \ + php /var/www/html/custom_apps/mitgliederverwaltung/vendor/bin/phpunit \ + -c /var/www/html/custom_apps/mitgliederverwaltung/phpunit.xml \ + --colors=always; \ + else \ + echo "Running suite $(suite)..."; \ + docker compose exec -u www-data -T nextcloud \ + php /var/www/html/custom_apps/mitgliederverwaltung/vendor/bin/phpunit \ + -c /var/www/html/custom_apps/mitgliederverwaltung/phpunit.xml \ + --testsuite $(suite) \ + --colors=always; \ + fi + # Remove volumes (full reset) clean: docker compose down -v