-
-
Save opdavies/72611f198ffd2da13f363ea65264b2a5 to your computer and use it in GitHub Desktop.
Docksal command to run PHPUnit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#: exec_target = cli | |
## Run automated PHPUnit tests. | |
## | |
## Usage: fin phpunit <args> | |
## | |
## If a core/phpunit.xml file does not exist, one is copied from | |
## .docksal/core/phpunit.xml if that file exists, or copied from the default | |
## core/phpunit.xml.dist file. | |
DOCROOT_PATH="${PROJECT_ROOT}/${DOCROOT}" | |
DRUPAL_CORE_PATH="${DOCROOT_PATH}/core" | |
run_tests() { | |
${PROJECT_ROOT}/vendor/bin/phpunit -c ${DRUPAL_CORE_PATH} "$@" | |
} | |
if [ ! -e ${DRUPAL_CORE_PATH}/phpunit.xml ]; then | |
if [ -e "${PROJECT_ROOT}/.docksal/drupal/core/phpunit.xml" ]; then | |
echo "Copying ${PROJECT_ROOT}/.docksal/drupal/core/phpunit.xml to ${DRUPAL_CORE_PATH}/phpunit.xml" | |
cp "${PROJECT_ROOT}/.docksal/drupal/core/phpunit.xml" ${DRUPAL_CORE_PATH}/phpunit.xml | |
run_tests "$@" | |
else | |
echo "Copying phpunit.xml.dist to phpunit.xml. Please edit it's values as needed and re-run 'fin phpunit'." | |
cp ${DRUPAL_CORE_PATH}/phpunit.xml.dist ${DRUPAL_CORE_PATH}/phpunit.xml | |
exit 1; | |
fi | |
else | |
run_tests "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment