PHPunit test call script update
Fix for default PHP set via getting version from default PHP. Add a verbose option and remove the fixed verbose setting from the phpunit config Update the options call to add a usage info block
This commit is contained in:
@@ -1,6 +1,40 @@
|
|||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
|
||||||
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
function error() {
|
||||||
|
if [ -t 1 ]; then echo "[MAK] ERROR: $*" >&2; fi; exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-t] [-v] [-p VERSION]
|
||||||
|
|
||||||
|
Runs all the PHP unit tests.
|
||||||
|
|
||||||
|
If -p is not set, the default intalled PHP is used.
|
||||||
|
|
||||||
|
Available options:
|
||||||
|
|
||||||
|
-h, --help Print this help and exit
|
||||||
|
-t, --testdox Enable testdox output for phpunit
|
||||||
|
-v, --verbose Enable verbose output for PHPunit
|
||||||
|
-p, --php VERSION Chose PHP version in the form of "N.N", if not found will exit
|
||||||
|
EOF
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# set base variables
|
||||||
|
BASE_PATH="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
||||||
|
PHPUNIT_CONFIG="${BASE_PATH}phpunit.xml";
|
||||||
|
PHP_BIN_PATH=$(which php);
|
||||||
|
if [ -z "${PHP_BIN_PATH}" ]; then
|
||||||
|
echo "Cannot find php binary";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
|
DEFAULT_PHP_VERSION=$(${PHP_BIN_PATH} -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;");
|
||||||
|
if [ -z "${DEFAULT_PHP_VERSION}" ]; then
|
||||||
|
echo "Cannot set default PHP version";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
# -c phpunit.xml
|
# -c phpunit.xml
|
||||||
# --testdox
|
# --testdox
|
||||||
# call with "-tt" to give verbose testdox output
|
# call with "-tt" to give verbose testdox output
|
||||||
@@ -8,16 +42,24 @@ base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
|||||||
# call with -p <php version number> to force a certain php version
|
# call with -p <php version number> to force a certain php version
|
||||||
|
|
||||||
opt_testdox="";
|
opt_testdox="";
|
||||||
php_bin="";
|
opt_verbose="";
|
||||||
|
php_version="";
|
||||||
|
no_php_version=0;
|
||||||
while [ -n "${1-}" ]; do
|
while [ -n "${1-}" ]; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-t | --testdox)
|
-t | --testdox)
|
||||||
opt_testdox="--testdox";
|
opt_testdox="--testdox";
|
||||||
;;
|
;;
|
||||||
|
-v | --verbose)
|
||||||
|
opt_verbose="--verbose";
|
||||||
|
;;
|
||||||
-p | --php)
|
-p | --php)
|
||||||
php_bin="/usr/bin/php${2-}";
|
php_version="${2-}";
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
# invalid option
|
# invalid option
|
||||||
-?*)
|
-?*)
|
||||||
error "[!] Unknown option: '$1'."
|
error "[!] Unknown option: '$1'."
|
||||||
@@ -26,6 +68,13 @@ while [ -n "${1-}" ]; do
|
|||||||
shift;
|
shift;
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
if [ -z "${php_version}" ]; then
|
||||||
|
php_version="${DEFAULT_PHP_VERSION}";
|
||||||
|
no_php_version=1;
|
||||||
|
fi;
|
||||||
|
php_bin="${PHP_BIN_PATH}${php_version}";
|
||||||
|
echo "Use PHP Version: ${php_version}";
|
||||||
|
|
||||||
if [ ! -f "${php_bin}" ]; then
|
if [ ! -f "${php_bin}" ]; then
|
||||||
echo "Set php ${php_bin} does not exist";
|
echo "Set php ${php_bin} does not exist";
|
||||||
exit;
|
exit;
|
||||||
@@ -33,11 +82,12 @@ fi;
|
|||||||
php_bin="${php_bin} ";
|
php_bin="${php_bin} ";
|
||||||
|
|
||||||
# Note 4dev/tests/bootstrap.php has to be set as bootstrap file in phpunit.xml
|
# Note 4dev/tests/bootstrap.php has to be set as bootstrap file in phpunit.xml
|
||||||
phpunit_call="${php_bin}${base}vendor/bin/phpunit ${opt_testdox} -c ${base}phpunit.xml ${base}4dev/tests/";
|
phpunit_call="${php_bin}${BASE_PATH}vendor/bin/phpunit ${opt_testdox} ${opt_verbose} -c ${PHPUNIT_CONFIG} ${BASE_PATH}4dev/tests/";
|
||||||
|
|
||||||
${phpunit_call};
|
${phpunit_call};
|
||||||
|
|
||||||
if [ -n "${php_bin}" ]; then
|
echo -e "\nPHPUnit Config: ${PHPUNIT_CONFIG}";
|
||||||
|
if [ "${no_php_version}" -eq 0 ]; then
|
||||||
echo "CALLED WITH PHP: ${php_bin}$(${php_bin} --version)";
|
echo "CALLED WITH PHP: ${php_bin}$(${php_bin} --version)";
|
||||||
else
|
else
|
||||||
echo "Default PHP used: $(php --version)";
|
echo "Default PHP used: $(php --version)";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<phpunit
|
<phpunit
|
||||||
cacheResultFile="/tmp/phpunit-corelibs.result.cache"
|
cacheResultFile="/tmp/phpunit-corelibs.result.cache"
|
||||||
colors="true"
|
colors="true"
|
||||||
verbose="true"
|
verbose="false"
|
||||||
convertDeprecationsToExceptions="true"
|
convertDeprecationsToExceptions="true"
|
||||||
bootstrap="4dev/tests/bootstrap.php"
|
bootstrap="4dev/tests/bootstrap.php"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user