Newer
Older
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
38
39
40
41
42
43
#!/usr/bin/env bash
# NAME
# phpunit.sh - Runs PHPUnit tests.
#
# SYNOPSIS
# bash phpunit.sh
#
# DESCRIPTION
# Run all Automatic Updates PHPUnit tests.
#
# It is assumed that this module is inside a Drupal core installation, in
# modules or modules/contrib. See setup_local_dev.sh.
cd "$(dirname "$0")" || exit 0;
# Find PHPUnit in Drupal core. Check up to three directories up.
DIR=$(pwd)
for i in {0..3}; do
DIR=$(dirname "$DIR")
PHPUNIT_BIN="$DIR/vendor/bin/phpunit"
PHPUNIT_CONFIG="$DIR/core/phpunit.xml"
if test -f "$PHPUNIT_BIN"; then
break
fi
done
# Exit if PHPUnit can't be found.
if test ! -f "$PHPUNIT_BIN"; then
echo "Could not find PHPUnit. Are you inside a Drupal site's 'modules' directory?"
exit 1
fi
# Exit if PHPUnit can't be found.
if test ! -f "$PHPUNIT_CONFIG"; then
echo "Could not find PHPUnit configuration. See setup_local_dev.sh."
exit 1
fi
# Run PHPUnit on the module directory.
php "$PHPUNIT_BIN" \
-c "$PHPUNIT_CONFIG" \
"$(cd .. && pwd)"