aboutsummaryrefslogtreecommitdiffstats
path: root/.ddev/commands/web/phpunit
blob: 126406a9afe915375da6f082b0dab1abca082c1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash

## 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

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 "$@"