topaz2/chef_boilerplate_php

View on GitHub
files/default/git/hooks/php/phpunit

Summary

Maintainability
Test Coverage
#!/bin/bash -e

PROJECT=`php -r "echo dirname(dirname(dirname(dirname(realpath('$0')))));"`

FILES=""
for FILE in `git diff --cached --name-only --diff-filter=ACMR HEAD | egrep \\\\.\(php\)\$`
do
  FILES="$FILES $PROJECT/$FILE"
done

if [ "$FILES" != "" ]
then
  echo "Running phpunit..."
  for TEST in `git diff --cached --name-only --diff-filter=ACMR HEAD | egrep \\Test\\.\(php\)\$`
  do
    phpunit app $TEST --stderr --configuration phpunit.xml.dist || exit $?
  done
fi

exit 0