-
-
Save ricardoboss/45df6ab57e258e8a1bd638697f18fec9 to your computer and use it in GitHub Desktop.
Bash script for running PHPUnit tests. Intended for use a pre-push git hook. Uses the project specific PHPUnit executable (vendor/bin/phpunit), the system-wide PHPUnit executable or phpunit.phar, whatever it finds first in this order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PHPUNIT_COMMAND="" | |
PHPUNIT_ARGS="--stderr --no-coverage" | |
# get phpunit executable (composer bin > system bin > phar file) | |
if [ -f "vendor/bin/phpunit" ]; then | |
PHPUNIT_COMMAND="vendor/bin/phpunit" | |
elif hash phpunit 2>/dev/null; then | |
PHPUNIT_COMMAND="phpunit" | |
elif [ -e phpunit.phar ]; then | |
PHPUNIT_COMMAND="phpunit.phar" | |
fi | |
# check if phpunit was found | |
if [ ! -z "$PHPUNIT_COMMAND" ]; then | |
if [ "phpunit.phar" = "$PHPUNIT_COMMAND" ]; then | |
$OUTPUT = `php "$PHPUNIT_COMMAND" $PHPUNIT_ARGS | tail -n 2` | |
else | |
$OUTPUT = `"$PHPUNIT_COMMAND" $PHPUNIT_ARGS | tail -n 2` | |
fi | |
echo $OUTPUT | |
fi | |
# do nothing if no phpunit was found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment