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

    [...]
This commit is contained in:
Zach Borboa
2021-11-23 21:53:32 -05:00
parent 860645c623
commit 31a65e2dfb
2 changed files with 24 additions and 0 deletions
+12
View File
@@ -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}" \
+12
View File
@@ -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