#!/bin/bash

# crmv@325074

set -e

# crmv@303843
# Run this command to launch unit and functional tests
# All additional parameters will be passed to phpunit

if [ ! -x "../vendor/bin/phpunit" ]; then
	echo "Installing DEV dependencies..."
	composer install --dev --working-dir=../
fi

USE_PHP=php

php_args=()

dbg=(
    # remote_enable=1
    # remote_autostart=On
    mode='debug,develop'
    start_with_request=yes  # override from 'trigger'

    # make sure to create SSH tunnel
    client_host=localhost
    client_port=9003  # different from base port

    # discover_client_host=1
    # start_with_request=yes
    # profiler_enable=1
)
# mapfile -tO "${#php_args[@]}" php_args < <(printf -- '-dxdebug.%s\n' "${dbg[@]}")

"$USE_PHP" "${php_args[@]}" '../vendor/bin/phpunit' --color "$@"
