Add script to run CLI tests that loads and exports test env vars

This commit is contained in:
Alejandro Celaya 2024-10-23 10:04:37 +02:00
parent 46601443f5
commit 442eea0ea7
3 changed files with 18 additions and 7 deletions

16
bin/test/run-cli-tests.sh Executable file
View file

@ -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

View file

@ -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",

View file

@ -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