diff --git a/bin/test/run-api-tests.sh b/bin/test/run-api-tests.sh index c115feac..1cbf948a 100755 --- a/bin/test/run-api-tests.sh +++ b/bin/test/run-api-tests.sh @@ -1,8 +1,10 @@ +#!/usr/bin/env sh + export APP_ENV=test export TEST_ENV=api -export TEST_RUNTIME=${TEST_RUNTIME:-"openswoole"} -export DB_DRIVER=${DB_DRIVER:-"postgres"} -export GENERATE_COVERAGE=${GENERATE_COVERAGE:-"no"} +export TEST_RUNTIME="${TEST_RUNTIME:-"openswoole"}" +export DB_DRIVER="${DB_DRIVER:-"postgres"}" +export GENERATE_COVERAGE="${GENERATE_COVERAGE:-"no"}" # Reset logs OUTPUT_LOGS=data/log/api-tests/output.log @@ -11,12 +13,12 @@ mkdir data/log/api-tests touch $OUTPUT_LOGS # Try to stop server just in case it hanged in last execution -[[ $TEST_RUNTIME == 'openswoole' ]] && vendor/bin/laminas mezzio:swoole:stop -[[ $TEST_RUNTIME == 'rr' ]] && bin/rr stop -f +[ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:stop +[ "$TEST_RUNTIME" = 'rr' ] && bin/rr stop -f echo 'Starting server...' -[[ $TEST_RUNTIME == 'openswoole' ]] && vendor/bin/laminas mezzio:swoole:start -d -[[ $TEST_RUNTIME == 'rr' ]] && bin/rr serve -p -c=config/roadrunner/.rr.dev.yml \ +[ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:start -d +[ "$TEST_RUNTIME" = 'rr' ] && bin/rr serve -p -c=config/roadrunner/.rr.dev.yml \ -o=http.address=0.0.0.0:9999 \ -o=logs.encoding=json \ -o=logs.channels.http.encoding=json \ @@ -29,8 +31,8 @@ sleep 2 # Let's give the server a couple of seconds to start vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always --log-junit=build/coverage-api/junit.xml $* testsExitCode=$? -[[ $TEST_RUNTIME == 'openswoole' ]] && vendor/bin/laminas mezzio:swoole:stop -[[ $TEST_RUNTIME == 'rr' ]] && bin/rr stop -c config/roadrunner/.rr.dev.yml -o=http.address=0.0.0.0:9999 +[ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:stop +[ "$TEST_RUNTIME" = 'rr' ] && bin/rr stop -c config/roadrunner/.rr.dev.yml -o=http.address=0.0.0.0:9999 # Exit this script with the same code as the tests. If tests failed, this script has to fail exit $testsExitCode