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

Use newer versions of PHPUnit #300

Closed
swissspidy opened this issue Jun 18, 2019 · 3 comments · Fixed by #301
Closed

Use newer versions of PHPUnit #300

swissspidy opened this issue Jun 18, 2019 · 3 comments · Fixed by #301

Comments

@swissspidy
Copy link

WordPress core runs tests using PHPUnit 7, 6, or 4, depending on the PHP version:

https://github.com/WordPress/wordpress-develop/blob/1f1cf751e5130249ee06684399f001ae4479e650/.travis.yml#L62-L82

wp-dev-lib however uses PHPUnit 4 or 5, depending on PHP version:

if [[ -z "$PHPUNIT_VERSION" ]]; then
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
PHPUNIT_VERSION='5.7'
elif [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
PHPUNIT_VERSION='4.8'
fi

Is there any chance wp-dev-lib could use more up-to-date PHPUnit versions as well?

@kasparsd
Copy link
Contributor

Could we require users to add the PHPUnit dependency to their project in composer.json instead?

A simple fix would be to check for an existing phpunit executable here before doing any install:

if check_should_execute 'phpunit'; then

as we do here already:

if check_should_execute 'phpunit' && ! command -v phpunit >/dev/null 2>&1; then

Thougts?

@kasparsd
Copy link
Contributor

Actually, the whole thing here might no longer be necessary:

if check_should_execute 'phpunit'; then
if [[ -z "$PHPUNIT_VERSION" ]]; then
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
PHPUNIT_VERSION='5.7'
elif [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
PHPUNIT_VERSION='4.8'
fi
fi
if [[ ! -z "$PHPUNIT_VERSION" ]]; then
mkdir -p $HOME/phpunit-bin/$PHPUNIT_VERSION
echo "Opting for phpunit $PHPUNIT_VERSION for PHP $TRAVIS_PHP_VERSION"
export PATH="$HOME/phpunit-bin/$PHPUNIT_VERSION:$PATH"
if [[ ! -e $HOME/phpunit-bin/$PHPUNIT_VERSION/phpunit ]]; then
wget -O $HOME/phpunit-bin/$PHPUNIT_VERSION/phpunit https://phar.phpunit.de/phpunit-$PHPUNIT_VERSION.phar
chmod +x $HOME/phpunit-bin/$PHPUNIT_VERSION/phpunit
fi
fi
fi

since we're already installing PHPunit during install_tools:

if check_should_execute 'phpunit' && ! command -v phpunit >/dev/null 2>&1; then
PHPUNIT_VERSION=${PHPUNIT_VERSION:-5.7}
echo "Downloading PHPUnit $PHPUNIT_VERSION phar"
download https://phar.phpunit.de/phpunit-$PHPUNIT_VERSION.phar "$TEMP_TOOL_PATH/phpunit"
chmod +x "$TEMP_TOOL_PATH/phpunit"
fi

which runs right after:

@swissspidy
Copy link
Author

@kasparsd Checking for an existing binary from composer makes sense to me. Adding that would be a nice enhancement still.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants