From 442eea0ea71d7a416fc161692f0d1a915b51f81b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 23 Oct 2024 10:04:37 +0200 Subject: [PATCH] Add script to run CLI tests that loads and exports test env vars --- bin/test/run-cli-tests.sh | 16 ++++++++++++++++ composer.json | 4 ++-- config/test/shlink-test.env | 5 ----- 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100755 bin/test/run-cli-tests.sh diff --git a/bin/test/run-cli-tests.sh b/bin/test/run-cli-tests.sh new file mode 100755 index 00000000..c97f8705 --- /dev/null +++ b/bin/test/run-cli-tests.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +export APP_ENV=test +export TEST_ENV=cli +export DB_DRIVER=maria + +# Load and export test env vars +set -a +. ./config/test/shlink-test.env +set +a + +vendor/bin/phpunit --order-by=random --testdox --testdox-summary -c phpunit-cli.xml $* +TESTS_EXIT_CODE=$? + +# Exit this script with the same code as the tests. If tests failed, this script has to fail +exit $TESTS_EXIT_CODE diff --git a/composer.json b/composer.json index 6f8feba4..2fe653e0 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "phpunit/phpunit": "^11.3", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", - "shlinkio/shlink-test-utils": "^4.1", + "shlinkio/shlink-test-utils": "^4.1.1", "symfony/var-dumper": "^7.0", "veewee/composer-run-parallel": "^1.3" }, @@ -136,7 +136,7 @@ "test:api:mssql": "DB_DRIVER=mssql composer test:api -- $*", "test:api:ci": "GENERATE_COVERAGE=yes composer test:api && vendor/bin/phpcov merge build/coverage-api --php build/coverage-api.cov && rm build/coverage-api/*.cov", "test:api:pretty": "GENERATE_COVERAGE=yes composer test:api && vendor/bin/phpcov merge build/coverage-api --html build/coverage-api/coverage-html && rm build/coverage-api/*.cov", - "test:cli": "APP_ENV=test DB_DRIVER=maria TEST_ENV=cli php vendor/bin/phpunit --order-by=random --testdox --testdox-summary -c phpunit-cli.xml", + "test:cli": "bin/test/run-cli-tests.sh", "test:cli:ci": "XDEBUG_MODE=coverage GENERATE_COVERAGE=yes composer test:cli && vendor/bin/phpcov merge build/coverage-cli --php build/coverage-cli.cov && rm build/coverage-cli/*.cov", "test:cli:pretty": "XDEBUG_MODE=coverage GENERATE_COVERAGE=yes composer test:cli && vendor/bin/phpcov merge build/coverage-cli --html build/coverage-cli/coverage-html && rm build/coverage-cli/*.cov", "swagger:validate": "php-openapi validate docs/swagger/swagger.json", diff --git a/config/test/shlink-test.env b/config/test/shlink-test.env index d0eac32a..a7126e10 100644 --- a/config/test/shlink-test.env +++ b/config/test/shlink-test.env @@ -1,8 +1,3 @@ # URL shortener DEFAULT_DOMAIN=s.test IS_HTTPS_ENABLED=false - -# Disable mercure integration during E2E tests -MERCURE_PUBLIC_HUB_URL=null -MERCURE_INTERNAL_HUB_URL=null -MERCURE_JWT_SECRET=null