#!/bin/sh set -eu suite=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) mkdir -p "$suite/tools" expected=c704fdd37c6c6ab7adb386f31b4e186cd51156801fa9028b5ea8099a2cd7f106 hash_file() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d ' ' -f 1 else shasum -a 256 "$1" | cut -d ' ' -f 1; fi } if [ -f "$suite/tools/phpunit.phar" ] && [ "$(hash_file "$suite/tools/phpunit.phar")" = "$expected" ]; then exit 0 fi tmp=$(mktemp "$suite/tools/phpunit.XXXXXX") trap 'rm -f "$tmp"' EXIT HUP INT TERM curl --fail --location --silent --show-error --output "$tmp" https://phar.phpunit.de/phpunit-11.5.57.phar [ "$(hash_file "$tmp")" = "$expected" ] || { echo 'PHPUnit checksum mismatch' >&2; exit 1; } chmod 644 "$tmp" mv "$tmp" "$suite/tools/phpunit.phar"