Skip to content

Commit e43d515

Browse files
committed
updated run_docker_tests script
1 parent 89ed451 commit e43d515

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

run_docker_tests.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
#!/bin/bash
22

3-
# Run tests for PHP 7.2
4-
echo -e "\n=============================================================\n"
5-
docker-compose run phpunit-7.2
6-
EXIT_CODE_7_2=$?
3+
PHP_VERSIONS=("7.2" "8.2")
4+
TESTS_PASSED=true
75

8-
# Run tests for PHP 8.2
9-
echo -e "\n=============================================================\n"
10-
docker-compose run phpunit-8.2
11-
EXIT_CODE_8_2=$?
6+
function run_phpunit_tests() {
7+
local php_version="$1"
8+
echo -e "\n================[ Testing PHP $php_version: ]=============================================\n"
9+
docker-compose run "phpunit-$php_version"
10+
return $?
11+
}
1212

13-
# Check exit codes and display messages
14-
if [ $EXIT_CODE_7_2 -eq 0 ] && [ $EXIT_CODE_8_2 -eq 0 ]; then
15-
echo -e "\n\n\e[32mTests passed successfully for both PHP 7.2 and PHP 8.2.\e[0m"
13+
# Loop through PHP versions
14+
for php_version in "${PHP_VERSIONS[@]}"; do
15+
run_phpunit_tests "$php_version"
16+
exit_code=$?
17+
18+
# Check if tests failed
19+
if [ $exit_code -ne 0 ]; then
20+
TESTS_PASSED=false
21+
break
22+
fi
23+
done
24+
25+
# Display messages based on test results
26+
if $TESTS_PASSED; then
27+
echo -e "\n\n\e[32mTests passed successfully for all PHP versions.\e[0m"
1628
else
1729
echo -e "\n\n\e[31mTests failed for at least one PHP version.\e[0m"
1830
fi
1931

2032
# Exit with the overall exit code
21-
exit $((EXIT_CODE_7_2 + EXIT_CODE_8_2))
33+
exit $exit_code

0 commit comments

Comments
 (0)