diff --git a/bin/test/run-api-tests.sh b/bin/test/run-api-tests.sh index 4c519a9b..ffc152b7 100755 --- a/bin/test/run-api-tests.sh +++ b/bin/test/run-api-tests.sh @@ -17,12 +17,8 @@ touch $OUTPUT_LOGS # Try to stop server just in case it hanged in last execution [ "$TEST_RUNTIME" = 'rr' ] && bin/rr stop -f -w . -# Resolve .env file absolute path, as it fails to load with relative paths -TESTS_DOTENV="${PWD}/config/test/shlink-test.env" - echo 'Starting server...' [ "$TEST_RUNTIME" = 'rr' ] && bin/rr serve -p -w . -c=config/roadrunner/.rr.test.yml \ - --dotenv "$TESTS_DOTENV" \ -o=logs.output="${PWD}/${OUTPUT_LOGS}" \ -o=logs.channels.http.output="${PWD}/${OUTPUT_LOGS}" \ -o=logs.channels.server.output="${PWD}/${OUTPUT_LOGS}" & diff --git a/bin/test/run-cli-tests.sh b/bin/test/run-cli-tests.sh index 96ea6cfa..60b97fcc 100755 --- a/bin/test/run-cli-tests.sh +++ b/bin/test/run-cli-tests.sh @@ -7,11 +7,6 @@ export GENERATE_COVERAGE="${GENERATE_COVERAGE:-"no"}" [ "$GENERATE_COVERAGE" != 'no' ] && export XDEBUG_MODE=coverage -# 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=$? diff --git a/config/container.php b/config/container.php index e207fe16..6ac07896 100644 --- a/config/container.php +++ b/config/container.php @@ -15,8 +15,11 @@ chdir(dirname(__DIR__)); require 'vendor/autoload.php'; -// Promote env vars from installer or dev config -loadEnvVarsFromConfig('config/params/*.php', enumValues(EnvVars::class)); +// Promote env vars from installer, dev config or test config +loadEnvVarsFromConfig( + EnvVars::isTestEnv() ? 'config/test/shlink_test_env.php' : 'config/params/*.php', + enumValues(EnvVars::class), +); // This is one of the first files loaded. Configure the timezone and memory limit here ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv()); diff --git a/config/test/shlink-test.env b/config/test/shlink-test.env deleted file mode 100644 index 48af9b6e..00000000 --- a/config/test/shlink-test.env +++ /dev/null @@ -1,5 +0,0 @@ -APP_ENV=test - -# URL shortener -DEFAULT_DOMAIN=s.test -IS_HTTPS_ENABLED=false diff --git a/config/test/shlink_test_env.php b/config/test/shlink_test_env.php new file mode 100644 index 00000000..f32d06db --- /dev/null +++ b/config/test/shlink_test_env.php @@ -0,0 +1,15 @@ +value => 'test', + + // URL shortener + EnvVars::DEFAULT_DOMAIN->value => 's.test', + EnvVars::IS_HTTPS_ENABLED->value => false, + +];