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.
This commit is contained in:
shahondin1624
2026-04-22 09:59:06 +02:00
parent 38858c8002
commit a9f3dc82ae
+35 -2
View File
@@ -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