From f9efecf8cc07feef3a20e8692576ab8d0c526c09 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 10 May 2024 22:20:04 +0200 Subject: Update config, phpunit and phpcs --- .ddev/commands/web/phpunit | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to '.ddev/commands/web/phpunit') 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 "$@" -- cgit v1.2.3