#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run phpunit inside the web container
## Usage: phpunit [flags] [args]
## Example: "ddev phpunit" or "ddev phpunit --stop-on-failure"
## ExecRaw: true

if ! command -v phpunit >/dev/null; then
  echo "phpunit is not available. You may need to 'ddev composer install'"
  exit 1
fi

# CHECK for local config.
if [ -f "phpunit.xml" ]; then
    # Defer to local config
    phpunit "$@"
else
    # Bootstrap Drupal tests and run all custom module tests.
    phpunit --bootstrap $PWD/$DDEV_DOCROOT/core/tests/bootstrap.php $DDEV_DOCROOT/modules/custom "$@"
fi
