forked from zenstruck/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpunit
More file actions
executable file
·83 lines (69 loc) · 2.06 KB
/
Copy pathphpunit
File metadata and controls
executable file
·83 lines (69 loc) · 2.06 KB
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
83
#!/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}" == *"dev"* ]] && [ "${REQUIRED_PHPUNIT_VERSION}" != "11.4" ]; then
echo 0;
elif [[ "${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 11.4 " != *" ${PHPUNIT_VERSION-9} "* ]]; then
echo "❌ PHPUNIT_VERSION should be one of 9, 10, 11, 11.4";
exit 1;
fi
SHOULD_UPDATE_PHPUNIT=$(check_phpunit_version "${PHPUNIT_VERSION}")
if [ "${SHOULD_UPDATE_PHPUNIT}" = "0" ]; then
echo "ℹ️ Upgrading PHPUnit to ${PHPUNIT_VERSION}"
if [ "${PHPUNIT_VERSION}" = "9" ]; then
composer update phpunit/phpunit:^9 -W --dev
else
if [ "${PHPUNIT_VERSION}" = "11.4" ]; then
composer update phpunit/phpunit:11.4.x-dev -W --dev
else
composer update "phpunit/phpunit:^${PHPUNIT_VERSION}" -W --dev
fi
fi
fi
### <<
### >> guess extensions
EXTENSION=""
if [ "${USE_DAMA_DOCTRINE_TEST_BUNDLE:-0}" = "1" ]; then
EXTENSION="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"
fi
### <<
### >> actually execute PHPUnit with the right options
case ${PHPUNIT_VERSION} in
"9")
if [ -z "${EXTENSION}" ]; then
vendor/bin/phpunit -c phpunit.xml.dist "$@"
else
vendor/bin/phpunit -c phpunit.xml.dist --extensions "${EXTENSION}" "$@"
fi
;;
"10")
# PHPUnit 10 does not have a --extension option
vendor/bin/phpunit -c phpunit-10.xml.dist "$@"
;;
"11"|"11.4")
if [ -z "${EXTENSION}" ]; then
vendor/bin/phpunit -c phpunit-10.xml.dist "$@"
else
vendor/bin/phpunit -c phpunit-10.xml.dist --extension "${EXTENSION}" "$@"
fi
;;
esac
### <<