Skip to content

Instantly share code, notes, and snippets.

@jasonbradley
Last active January 22, 2020 08:40
Show Gist options
  • Save jasonbradley/38b8be1098b5cc677c74 to your computer and use it in GitHub Desktop.
Save jasonbradley/38b8be1098b5cc677c74 to your computer and use it in GitHub Desktop.
Run PHP Unit tests bash script. Looks for phpunit command availability or phpunit.phar in the same location. It will download the phar file if neither is found.
#!/bin/bash
PHPUNIT_COMMAND=""
MEMORY_LIMIT=512M
PHPUNIT_VERSION="4.1.3"
if hash phpunit 2>/dev/null;
then
PHPUNIT_COMMAND="phpunit"
elif [ -e phpunit.phar ]
then
PHPUNIT_COMMAND="phpunit.phar"
else
wget -qO phpunit.phar https://phar.phpunit.de/phpunit-"$PHPUNIT_VERSION".phar --no-check-certificate
PHPUNIT_COMMAND="phpunit.phar"
fi
if [ ! -z "$PHPUNIT_COMMAND" ]
then
if [ "phpunit.phar" = "$PHPUNIT_COMMAND" ]
then
php "$PHPUNIT_COMMAND" -d memory_limit="$MEMORY_LIMIT" -c app $*
else
"$PHPUNIT_COMMAND" -d memory_limit="$MEMORY_LIMIT" -c app $*
fi
else
echo "PHPUNIT/PHPUNIT.PHAR NOT FOUND."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment