Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
Always install a valid version of phpunit (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd authored Jul 4, 2019
1 parent 2a12c1c commit 3314df6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ dist: xenial
language: php

php:
- '7.2'
- "7.2"
- "7.0"

services:
- mysql
Expand Down
35 changes: 24 additions & 11 deletions scripts/check-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ function realpath {
php -r 'echo realpath( $argv[1] );' "$1"
}

# Return true (exit code 0) if the installed version of PHP is at least the reference.
function php_is_atleast () {
php -r 'if ( ! version_compare( phpversion(), $argv[1], ">=" ) ) { exit( 1 ); }' "$1"
}

# Return true (exit code 0) if the installed version of PHP is above the reference.
function php_is_above () {
php -r 'if ( ! version_compare( phpversion(), $argv[1], ">" ) ) { exit( 1 ); }' "$1"
}

# Deprecated: same as php_is_above.
function min_php_version () {
php -r 'if ( version_compare( phpversion(), $argv[1], "<" ) ) { exit( 1 ); }' "$1"
php_is_above "$1"
}

function upsearch {
Expand Down Expand Up @@ -394,9 +405,9 @@ function download {

function can_generate_coverage_clover {
if [ -e .coveralls.yml ] && [ -e composer.json ] && check_should_execute 'coverage'; then
if min_php_version "5.5.0" && cat composer.json | grep -Eq '"php-coveralls/php-coveralls"\s*:\s*"([(\^|~)]*(2|1.1)[0-9.]*|dev-master)"'; then
if php_is_above "5.5.0" && cat composer.json | grep -Eq '"php-coveralls/php-coveralls"\s*:\s*"([(\^|~)]*(2|1.1)[0-9.]*|dev-master)"'; then
return 0
elif min_php_version "5.3.3" && cat composer.json | grep -Eq '"php-coveralls/php-coveralls"\s*:\s*"[(\^|~)]*[0-9.]*"'; then
elif php_is_above "5.3.3" && cat composer.json | grep -Eq '"php-coveralls/php-coveralls"\s*:\s*"[(\^|~)]*[0-9.]*"'; then
return 0
fi
fi
Expand All @@ -414,13 +425,13 @@ function install_tools {
mkdir -p "$TEMP_TOOL_PATH"
PATH="$TEMP_TOOL_PATH:$PATH"

if ! min_php_version "5.3.0" && check_should_execute 'composer'; then
if ! php_is_above "5.3.0" && check_should_execute 'composer'; then
pecl install phar
DEV_LIB_SKIP="$DEV_LIB_SKIP,composer"
fi

# Skip installing Composer when the PHP version does not meet the php-coveralls package requirements.
if ! min_php_version "5.5.0" && [ -e composer.json ] && check_should_execute 'composer' && cat composer.json | grep -Eq '"satooshi/php-coveralls"\s*:\s*"dev-master"'; then
if ! php_is_above "5.5.0" && [ -e composer.json ] && check_should_execute 'composer' && cat composer.json | grep -Eq '"satooshi/php-coveralls"\s*:\s*"dev-master"'; then
DEV_LIB_SKIP="$DEV_LIB_SKIP,composer"
fi

Expand Down Expand Up @@ -451,16 +462,18 @@ function install_tools {

# Install PHP tools.
if [ -s "$TEMP_DIRECTORY/paths-scope-php" ]; then
if check_should_execute 'phpunit' && ! command -v phpunit >/dev/null 2>&1; then
# Ensure a valid version of phpunit exists. Versions installed with Composer
# will be loaded first because of the directory order in $PATH defined above.
if check_should_execute 'phpunit'; then
if [ -z "$PHPUNIT_VERSION" ]; then
if ! min_php_version "7.1"; then
PHPUNIT_VERSION="4"

if php_is_atleast "7.1"; then
PHPUNIT_VERSION="7"
elif ! min_php_version "7.0"; then
elif php_is_atleast "7.0"; then
PHPUNIT_VERSION="6"
elif ! min_php_version "5.6"; then
elif php_is_atleast "5.6"; then
PHPUNIT_VERSION="5"
else
PHPUNIT_VERSION="4"
fi
fi

Expand Down

0 comments on commit 3314df6

Please sign in to comment.