aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.ddev/commands/web/phpunit38
1 files changed, 23 insertions, 15 deletions
diff --git a/.ddev/commands/web/phpunit b/.ddev/commands/web/phpunit
index b86cc32..5026539 100755
--- a/.ddev/commands/web/phpunit
+++ b/.ddev/commands/web/phpunit
@@ -2,22 +2,37 @@
## Description: Run phpunit in the ddev environment
## Usage: phpunit
-## Example: ddev phpunit [coverage|debug] [...phpunit args]
-
-# 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
+## Example: ddev phpunit coverage
+
+# The meaning of the first arg is:
+#
+# - setup: Create the test DB for the current database engine
+# - coverage: Produce coverage info in tests/results/coverage
+# - debug: Runs the tests with the debugger enabled
+# - profile: Collects profiling information from the test run.
+#
+# The first arg can also be empty, in which case the tests are run
+# without enabling any of the debugger modes.
+#
+# Using coverage, debug or profile required that xdebug is enabled.
set -e
+export XDEBUG_CONFIG="output_dir=tests/results"
+
+export HZ_TEST_DB_HOST=db
+export HZ_TEST_DB_USER=test_user
+export HZ_TEST_DB_PASS=hubzilla
+export HZ_TEST_DB_TYPE=$DDEV_DATABASE_FAMILY
+export HZ_TEST_DB_ROOT_USER=db
+export HZ_TEST_DB_ROOT_PASS=db
+
case $1 in
coverage | debug | profile) mode=$1; shift ;;
+ setup) tests/create_test_db.sh; exit ;;
*) 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
@@ -26,11 +41,4 @@ 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=test_user
-export HZ_TEST_DB_PASS=hubzilla
-export HZ_TEST_DB_TYPE=$DDEV_DATABASE_FAMILY
-
XDEBUG_MODE=$mode vendor/bin/phpunit -c tests/phpunit.xml $extra_args "$@"