2025-06-10 20:14:43 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
# This script runs unit tests locally in environment similar to Travis-CI
|
2025-07-27 19:58:08 +02:00
|
|
|
# It runs tests in different PHP versions with suitable PHPUnit version.
|
2025-06-10 20:14:43 +02:00
|
|
|
#
|
|
|
|
|
# You can see results of unit tests execution in console.
|
|
|
|
|
# Also all execution logs are saved to files phpunit_<date-time>.log
|
|
|
|
|
#
|
|
|
|
|
# Prerequisites for running unit tests on local machine:
|
2025-07-27 19:58:08 +02:00
|
|
|
# - docker (modern version with compose built-in)
|
2025-06-10 20:14:43 +02:00
|
|
|
#
|
|
|
|
|
# You can find definition of all test environments in folder testenv/
|
|
|
|
|
# This folder is not automatically synced with .travis.yml
|
|
|
|
|
# If you add new PHP version to .travis.yml then you'll need to adjust files in testenv/
|
|
|
|
|
|
|
|
|
|
cd testenv
|
|
|
|
|
|
|
|
|
|
# build containers and run tests
|
2025-07-27 19:58:08 +02:00
|
|
|
docker compose build && docker compose up php-74 && docker compose up php-83
|
2025-06-10 20:14:43 +02:00
|
|
|
|
|
|
|
|
# save logs to log file
|
2025-07-27 19:58:08 +02:00
|
|
|
docker compose logs --no-color --timestamps | sort >"../phpunit_$(date '+%Y%m%d-%H%M%S').log"
|
2025-06-10 20:14:43 +02:00
|
|
|
|
|
|
|
|
# remove containers
|
2025-07-27 19:58:08 +02:00
|
|
|
docker compose rm -f
|