Skip to content

Instantly share code, notes, and snippets.

@luispabon
Created February 8, 2018 11:23
Show Gist options
  • Save luispabon/43efa771e74cebec83612eab21cc2b42 to your computer and use it in GitHub Desktop.
Save luispabon/43efa771e74cebec83612eab21cc2b42 to your computer and use it in GitHub Desktop.
phpunit runner: first your projects, fall back to phar
#!/bin/bash
###
# Copyright (C) 2018 Luis Pabon
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.
###
# This script will try to run first phpunit installed in your project (assumes standard vendor bin location, modify if otherwise)
# then fall back to a phar installed version.
# Usage: create and chmod +x an empty file somewhere in your path (eg ~/bin/phpunit) then tweak PHPUNIT_PHAR below for your system.
###
PHPUNIT_PROJECT="vendor/bin/phpunit"
PHPUNIT_PHAR="${HOME}/bin/phpunit-phar/phpunit-latest"
if [[ -f ${PHPUNIT_PROJECT} ]]; then
${PHPUNIT_PROJECT} $@
else
${PHPUNIT_PHAR} $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment