Skip to content

Instantly share code, notes, and snippets.

@ngyuki
Created July 16, 2013 16:23
Show Gist options
  • Save ngyuki/6010262 to your computer and use it in GitHub Desktop.
Save ngyuki/6010262 to your computer and use it in GitHub Desktop.
function phpunit
{
local root="${PWD}"
while [ -n "${root}" ]; do
if [ -x "${root}/vendor/bin/phpunit" ]; then
break
fi
root="${root%/*}"
done
if [ -z "${root}" ]; then
command phpunit "$@"
return $?
fi
local cmd=("${root}/vendor/bin/phpunit")
local dir xml
for dir in "/tests/" "/" ; do
for xml in "phpunit.xml.dist" "phpunit.xml"; do
if [ -e "${root}${dir}${xml}" ]; then
cmd=("${cmd[@]}" "--configuration=${root}${dir}")
break 2
fi
done
done
cmd=("${cmd[@]}" "--colors")
"${cmd[@]}" "$@" |cat
return ${PIPESTATUS[0]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment