-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
phpunit
executable file
·82 lines (64 loc) · 2.12 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
set -o errexit
set -o nounset
check_phpunit_version() {
INSTALLED_PHPUNIT_VERSION=$(composer info phpunit/phpunit | grep versions | cut -c 14-)
REQUIRED_PHPUNIT_VERSION="${1?}"
if [[ "${INSTALLED_PHPUNIT_VERSION}" == "${REQUIRED_PHPUNIT_VERSION}"* ]]; then
echo 1;
else
echo 0;
fi
}
### >> load env vars from .env files if not in CI and not from a composer script
if [ -z "${CI:-}" ] && [ -z "${COMPOSER_BINARY:-}" ] ; then
source .env
if [ -f .env.local ]; then
source .env.local
fi
fi
### <<
### >> update PHPUnit if needed
if [[ " 9 10 11 " != *" ${PHPUNIT_VERSION-9} "* ]]; then
echo "❌ PHPUNIT_VERSION should be one of 9, 10, 11";
exit 1;
fi
SHOULD_UPDATE_PHPUNIT=$(check_phpunit_version "${PHPUNIT_VERSION}")
if [ "${SHOULD_UPDATE_PHPUNIT}" = "0" ]; then
echo "ℹ️ Upgrading PHPUnit to ${PHPUNIT_VERSION}"
composer update "phpunit/phpunit:^${PHPUNIT_VERSION}" -W
fi
### <<
### >> actually execute PHPUnit with the right options
DAMA_EXTENSION="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"
FOUNDRY_EXTENSION="Zenstruck\Foundry\PHPUnit\FoundryExtension"
if [ "${USE_FOUNDRY_PHPUNIT_EXTENSION:-0}" = "1" ] && [ "${PHPUNIT_VERSION}" != "11" ]; then
echo "❌ USE_FOUNDRY_PHPUNIT_EXTENSION could only be used with PHPUNIT_VERSION=11";
exit 1;
fi
PHPUNIT_EXEC="vendor/bin/phpunit"
case ${PHPUNIT_VERSION} in
"9")
PHPUNIT_EXEC="${PHPUNIT_EXEC} -c phpunit.xml.dist"
if [ "${USE_DAMA_DOCTRINE_TEST_BUNDLE:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extensions ${DAMA_EXTENSION}"
fi
;;
"10")
# PHPUnit 10 does not have a --extension option
PHPUNIT_EXEC="${PHPUNIT_EXEC} -c phpunit-10.xml.dist"
;;
"11")
PHPUNIT_EXEC="${PHPUNIT_EXEC} -c phpunit-10.xml.dist"
if [ "${USE_DAMA_DOCTRINE_TEST_BUNDLE:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension "${DAMA_EXTENSION}""
fi
if [ "${USE_FOUNDRY_PHPUNIT_EXTENSION:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension "${FOUNDRY_EXTENSION}""
fi
;;
esac
PHPUNIT_EXEC="${PHPUNIT_EXEC} ${@}"
echo "${PHPUNIT_EXEC}"
$PHPUNIT_EXEC
### <<