Skip to content

Commit 034b483

Browse files
committed
Move PHPUnit shims to test script
1 parent 5d3e80a commit 034b483

File tree

2 files changed

+37
-50
lines changed

2 files changed

+37
-50
lines changed

tests/before_script.sh

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2-
cd "${SCRIPT_DIR}"
3-
4-
# Use composer's phpunit and phpcs by adding composer bin directory to the path environment variable.
5-
export PATH="${PWD}/vendor/bin:${PATH}"
6-
7-
remove_expectWarning() {
8-
# Fix "Call to undefined method CurlTest\CurlTest::expectWarning()".
9-
sed -i'' -e"/->expectWarning(/d" "$(pwd)/tests/PHPCurlClass/PHP"*
10-
}
11-
12-
replace_assertStringContainsString() {
13-
# -->assertStringContainsString(
14-
# +->assertContains(
15-
find='->assertStringContainsString('
16-
replace='->assertContains('
17-
sed -i'' -e"s/${find}/${replace}/" "$(pwd)/tests/PHPCurlClass/PHP"*
18-
}
19-
20-
phpunit_v6_5_shim() {
21-
remove_expectWarning
22-
replace_assertStringContainsString
23-
}
24-
25-
phpunit_v7_5_shim() {
26-
remove_expectWarning
27-
}
28-
29-
phpunit_v8_1_shim() {
30-
remove_expectWarning
31-
}
32-
331
start_php_servers() {
342
for i in $(seq 0 6); do
353
port=8000
@@ -49,24 +17,6 @@ composer install --prefer-source --no-interaction
4917
# Let test server know we should allow testing.
5018
export PHP_CURL_CLASS_TEST_MODE_ENABLED="yes"
5119

52-
# Determine which phpunit to use.
53-
if [[ -f "../vendor/bin/phpunit" ]]; then
54-
phpunit_to_use="../vendor/bin/phpunit"
55-
else
56-
phpunit_to_use="phpunit"
57-
fi
58-
59-
phpunit_version="$("${phpunit_to_use}" --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
60-
echo "${phpunit_version}"
61-
62-
if [[ "${phpunit_version}" == "6.5."* ]]; then
63-
phpunit_v6_5_shim
64-
elif [[ "${phpunit_version}" == "7.5."* ]]; then
65-
phpunit_v7_5_shim
66-
elif [[ "${phpunit_version}" == "8.1."* ]]; then
67-
phpunit_v8_1_shim
68-
fi
69-
7020
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then
7121
start_php_servers
7222
elif [[ "${CI_PHP_VERSION}" == "7.1" ]]; then

tests/script.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ cd "${SCRIPT_DIR}"
44
# Use composer's phpunit and phpcs by adding composer bin directory to the path environment variable.
55
export PATH="${PWD}/vendor/bin:${PATH}"
66

7+
remove_expectWarning() {
8+
# Fix "Call to undefined method CurlTest\CurlTest::expectWarning()".
9+
sed -i'' -e"/->expectWarning(/d" "./PHPCurlClass/PHP"*
10+
}
11+
12+
replace_assertStringContainsString() {
13+
# -->assertStringContainsString(
14+
# +->assertContains(
15+
find='->assertStringContainsString('
16+
replace='->assertContains('
17+
sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"*
18+
}
19+
20+
phpunit_v6_5_shim() {
21+
remove_expectWarning
22+
replace_assertStringContainsString
23+
}
24+
25+
phpunit_v7_5_shim() {
26+
remove_expectWarning
27+
}
28+
29+
phpunit_v8_1_shim() {
30+
remove_expectWarning
31+
}
32+
733
errors=()
834

935
source "check_syntax.sh"
@@ -18,6 +44,17 @@ else
1844
phpunit_to_use="phpunit"
1945
fi
2046

47+
phpunit_version="$("${phpunit_to_use}" --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
48+
echo "${phpunit_version}"
49+
50+
if [[ "${phpunit_version}" == "6.5."* ]]; then
51+
phpunit_v6_5_shim
52+
elif [[ "${phpunit_version}" == "7.5."* ]]; then
53+
phpunit_v7_5_shim
54+
elif [[ "${phpunit_version}" == "8.1."* ]]; then
55+
phpunit_v8_1_shim
56+
fi
57+
2158
# Run tests.
2259
"${phpunit_to_use}" --version
2360
"${phpunit_to_use}" --configuration "phpunit.xml" --debug --verbose

0 commit comments

Comments
 (0)