Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Custom PHPUnit script for CakePHP on NetBaeans 8.0
#!/usr/bin/env bash
##
#
# Custom PHPUnit script for CakePHP on NetBaeans 8.0
#
# @author Takashi Nojima [http://php-tips.com]
# @copyright 2014 Takashi Nojima
##
PROJECT_ROOT=$(cd "$(dirname "$(dirname "$0")")" && pwd)
CAKE=app/Console/cake
XDEBUG_CONFIG="idekey=netbeans-xdebug"
cd "$PROJECT_ROOT"
## parse options
while [[ $# -gt 2 ]] ; do
#echo ">> ${1} ${2}"
case $1 in
'--colors' )
COLORS=1
;;
'--log-junit' )
JUNITLOG="$2"
shift
;;
'--bootstrap' )
BOOTSTRAP="$2"
shift
;;
'--filter' )
FILTER="$2"
shift
;;
'--coverage-clover' )
COVERAGE=$2
shift
;;
esac
shift
done
SUITE=$1
RUN=$2
RUN=${RUN/--run=/}
## debug print
#echo "COLORS = $COLORS"
#echo "JUNITLOG = $JUNITLOG"
#echo "BOOTSTRAP = $BOOTSTRAP"
#echo "FILTER = $FILTER"
#echo "COVERAGE = $COVERAGE"
#echo "SUITE = $SUITE"
#echo "RUN = $RUN"
## Build test command
COMMAND="XDEBUG_CONFIG=${XDEBUG_CONFIG} ${CAKE} test --stderr --log-junit \"${JUNITLOG}\""
if [[ -n "$FILTER" ]] ; then
COMMAND="${COMMAND} --filter \"${FILTER}\""
fi
if [[ -n "$COVERAGE" ]] ; then
COMMAND="${COMMAND} --coverage-clover \"${COVERAGE}\""
fi
COMMAND="${COMMAND} \"${RUN}\""
## Execute
#echo $COMMAND
eval $COMMAND
#!/usr/bin/env bash
##
#
# Custom PHPUnit script for CakePHP 1.x on NetBaeans 8.0
#
# require Stagehand_TestRunner <= 3.6 (see: https://github.com/piece/stagehand-testrunner/tree/3.0)
#
# @author Takashi Nojima [http://php-tips.com]
# @copyright 2014 Takashi Nojima
##
PROJECT_ROOT=$(cd "$(dirname "$(dirname "$0")")" && pwd)
TESTRUNNER=testrunner
APP="$PROJECT_ROOT/app"
CAKE_CORE="$PROJECT_ROOT/cake"
XDEBUG_CONFIG="idekey=netbeans-xdebug"
cd "$PROJECT_ROOT"
## parse options
while [[ $# -gt 2 ]] ; do
#echo ">> ${1} ${2}"
case $1 in
'--colors' )
COLORS=1
;;
'--log-junit' )
JUNITLOG="$2"
shift
;;
'--bootstrap' )
BOOTSTRAP="$2"
shift
;;
'--filter' )
FILTER="$2"
shift
;;
'--coverage-clover' )
COVERAGE=$2
shift
;;
esac
shift
done
SUITE=$1
RUN=$2
## debug print
#echo "COLORS = $COLORS"
#echo "JUNITLOG = $JUNITLOG"
#echo "BOOTSTRAP = $BOOTSTRAP"
#echo "FILTER = $FILTER"
#echo "COVERAGE = $COVERAGE"
#echo "SUITE = $SUITE"
#echo "RUN = $RUN"
RUN=${RUN/--run=/}
METHOD=${FILTER//[\%\\b]/}
if [[ -n "$FILTER" && -n "$COVERAGE" ]] ; then
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" --test-method "$METHOD" "$RUN"
elif [[ -n "$FILTER" ]] ; then
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" --test-method "$METHOD" "$RUN"
elif [[ -n "$COVERAGE" ]] ; then
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" "$RUN"
else
XDEBUG_CONFIG=$XDEBUG_CONFIG $TESTRUNNER cakephp --cakephp-app-path="$APP" --cakephp-core-path="$CAKE_CORE" --log-junit "$JUNITLOG" "$RUN"
fi
Owner
nojimage commented Jun 6, 2014

プロジェクトフォルダ内のnbproject/直下に設置するのを前提

Owner

Stagehand_TestRunner を使えば 1.3系でも動かせる。 (testrunner.sh)
ただし、カバレッジ測定やエラー発生時のコードには飛べない。

Owner
nojimage commented Sep 9, 2014

引数の数チェックを修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment