From 31a65e2dfbae267e566bb6ebafbf790b946641b0 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Tue, 23 Nov 2021 21:53:32 -0500 Subject: [PATCH] Remove void return type when running tests on PHP 7.0 The void return type was implemented in PHP 7.1 and PHP 7.0 treats the void return type as a class name. Errors: 1) CurlTest\CurlTest::testExtensionsLoaded TypeError: Return value of CurlTest\CurlTest::setUp() must be an instance of CurlTest\void, none returned /home/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/PHPCurlClassTest.php:18 2) CurlTest\CurlTest::testCaseInsensitiveArrayGet TypeError: Return value of CurlTest\CurlTest::setUp() must be an instance of CurlTest\void, none returned /home/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/PHPCurlClassTest.php:18 3) CurlTest\CurlTest::testCaseInsensitiveArraySet TypeError: Return value of CurlTest\CurlTest::setUp() must be an instance of CurlTest\void, none returned /home/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/PHPCurlClassTest.php:18 [...] --- tests/ci.sh | 12 ++++++++++++ tests/run.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/ci.sh b/tests/ci.sh index 78be95e..2ce5ae0 100755 --- a/tests/ci.sh +++ b/tests/ci.sh @@ -24,6 +24,14 @@ phpunit_v8_1_shim() { remove_expectWarning } +php_v7_0_shim() { + # -protected function setUp(): void + # +protected function setUp() + find='protected function setUp(): void' + replace='protected function setUp()' + sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"* +} + set -x composer self-update @@ -76,6 +84,10 @@ elif [[ "${phpunit_version}" == "8.1."* ]]; then phpunit_v8_1_shim fi +if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then + php_v7_0_shim +fi + # Run tests. "${phpunit_to_use}" --version "${phpunit_to_use}" \ diff --git a/tests/run.sh b/tests/run.sh index 112cb0b..079df22 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -24,6 +24,14 @@ phpunit_v8_1_shim() { remove_expectWarning } +php_v7_0_shim() { + # -protected function setUp(): void + # +protected function setUp() + find='protected function setUp(): void' + replace='protected function setUp()' + sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"* +} + set -x # Use composer's phpunit and phpcs by adding composer bin directory to the path environment variable. @@ -73,6 +81,10 @@ elif [[ "${phpunit_version}" == "8.1."* ]]; then phpunit_v8_1_shim fi +if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then + php_v7_0_shim +fi + # Run tests. extra_args="${@}" "${phpunit_to_use}" --version