-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
phpunit
37 lines (32 loc) · 1.29 KB
/
phpunit
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
37
#!/usr/bin/env bash
#: exec_target = cli
## Creates a phpunit.xml file and runs PHPUnit tests in Drupal 8
##
## Usage: fin phpunit <args>
##
## This first ensures that a `core/phpunit.xml` file exists, either by copying a
## stub from `.docksal/drupal/core/phpunit.xml` if that exists, or copying and
## renaming `core/phpunit.xml.dist`.
##
## If `core/phpunit.xml` exists, the phpunit command with then be run, appending
## any optional arguments such as the directory path (run `fin phpunit -h`) to
## see a full list of options.
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."
echo "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