diff options
Diffstat (limited to '.ddev/commands/web')
-rwxr-xr-x | .ddev/commands/web/phpunit | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/.ddev/commands/web/phpunit b/.ddev/commands/web/phpunit index 1a75bc7..126406a 100755 --- a/.ddev/commands/web/phpunit +++ b/.ddev/commands/web/phpunit @@ -2,6 +2,35 @@ ## Description: Run phpunit in the ddev environment ## Usage: phpunit -## Example: ddev phpunit +## Example: ddev phpunit [coverage|debug] [...phpunit args] -XDEBUG_MODE=coverage vendor/bin/phpunit -c tests/phpunit.xml --coverage-html=tests/results/coverage "$@" +# if first arg is either `coverage` or `debug`, set the xdebug mode +# accordingly. Default mode is `develop`, to get the built in dev +# helpers in xdebug. +# See https://xdebug.org/docs/all_settings#mode + +set -e + +case $1 in + coverage | debug | profile) mode=$1; shift ;; + *) mode=off +esac + +# DB_ROOT_USER=db tests/create_test_db_pgsql.sh + +# Clean out old logs +[ -a tests/results/unit_test.log ] && rm tests/results/unit_test.log + +# Run the tests +if [ "$mode" == "coverage" ]; then + extra_args='--coverage-html=tests/results/coverage'; +fi + +export XDEBUG_CONFIG="output_dir=tests/results" + +export HZ_TEST_DB_HOST=db +export HZ_TEST_DB_USER=db +export HZ_TEST_DB_PASS=db +export HZ_TEST_DB_TYPE=$DDEV_DATABASE_FAMILY + +XDEBUG_MODE=$mode vendor/bin/phpunit -c tests/phpunit.xml $extra_args "$@" |