File tree Expand file tree Collapse file tree 1 file changed +24
-12
lines changed
Expand file tree Collapse file tree 1 file changed +24
-12
lines changed Original file line number Diff line number Diff line change 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"
1628else
1729 echo -e " \n\n\e[31mTests failed for at least one PHP version.\e[0m"
1830fi
1931
2032# Exit with the overall exit code
21- exit $(( EXIT_CODE_ 7 _ 2 + EXIT_CODE_ 8 _ 2 ))
33+ exit $exit_code
You can’t perform that action at this time.
0 commit comments