Skip to content

Instantly share code, notes, and snippets.

@nojimage
Last active August 29, 2015 14:02
Show Gist options
  • Save nojimage/58796a9236296824f298 to your computer and use it in GitHub Desktop.
Save nojimage/58796a9236296824f298 to your computer and use it in GitHub Desktop.
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
@nojimage
Copy link
Author

nojimage commented Jun 6, 2014

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

@nojimage
Copy link
Author

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

@nojimage
Copy link
Author

nojimage commented Sep 9, 2014

引数の数チェックを修正

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