From 922ff9bdc8a7fd0192be8aa124e9928042a91536 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Tue, 23 Mar 2021 23:08:08 -0400 Subject: [PATCH] Fix tests running with older versions of PHPUnit --- tests/before_script.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/before_script.sh b/tests/before_script.sh index 4bcbe5e..562f2f2 100755 --- a/tests/before_script.sh +++ b/tests/before_script.sh @@ -20,6 +20,10 @@ phpunit_v7_5_shim() { remove_expectWarning } +phpunit_v8_1_shim() { + remove_expectWarning +} + start_php_servers() { for i in $(seq 0 6); do port=8000 @@ -39,11 +43,27 @@ composer install --prefer-source --no-interaction # Let test server know we should allow testing. export PHP_CURL_CLASS_TEST_MODE_ENABLED="yes" -if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then +# Determine which phpunit to use. +if [[ -f "../vendor/bin/phpunit" ]]; then + phpunit_to_use="../vendor/bin/phpunit" +else + phpunit_to_use="phpunit" +fi + +phpunit_version="$("${phpunit_to_use}" --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")" +echo "${phpunit_version}" + +if [[ "${phpunit_version}" == "6.5."* ]]; then phpunit_v6_5_shim +elif [[ "${phpunit_version}" == "7.5."* ]]; then + phpunit_v7_5_shim +elif [[ "${phpunit_version}" == "8.1."* ]]; then + phpunit_v8_1_shim +fi + +if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then start_php_servers elif [[ "${CI_PHP_VERSION}" == "7.1" ]]; then - phpunit_v7_5_shim start_php_servers elif [[ "${CI_PHP_VERSION}" == "7.2" ]]; then start_php_servers