Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure PHPUnit tests runs when using PHP 7.2+ in the Travis builds #22140

Merged
merged 1 commit into from Dec 6, 2018

Conversation

rodrigoprimo
Copy link
Contributor

Changes proposed in this Pull Request:

Due to a recent change in the Travis environment, WooCommerce unit tests stopped working with the following error (see for example https://travis-ci.org/woocommerce/woocommerce/jobs/463470674#L876) in the PHP 7.2 and 7.3 build jobs:

Fatal error: Class PHPUnit_Util_Test may not inherit from final class (PHPUnit\Util\Test) in /tmp/wordpress-tests-lib/includes/phpunit6-compat.php on line 18

This error is happening because Travis started ignoring the PHPUnit version that we install manually via Composer (tests/bin/travis.sh#L6) and started using the PHPUnit version that is shipped with each of its PHP docker images. This means that for the docker images running PHP 7.2 and 7.3, PHPUnit 7 is used, but the WordPress unit test framework is not compatible with PHPUnit 7 (see WordPress core ticket https://core.trac.wordpress.org/ticket/43218) and produces the error above. I believe that this is happening because Travis changed the directory where it installs composer global packages from $HOME/.composer/ to $HOME/.config/composer/ (travis-ci/travis-ci#7289 (comment)) and we add $HOME/.composer/vendor/bin:$PATH to the $PATH. So this commit simply updates the path in the line where we add it to the $PATH.

I tried to use composer exec instead of updating $PATH, but that didn't work for PHP 5.2.

How to test the changes in this Pull Request:

  1. Make sure all Travis build jobs pass

Due to a recent change in the Travis environment, WooCommerce unit tests stopped working with the following error (see for example https://travis-ci.org/woocommerce/woocommerce/jobs/463470674#L876) in the PHP 7.2 and 7.3 build jobs:

Fatal error: Class PHPUnit_Util_Test may not inherit from final class (PHPUnit\Util\Test) in /tmp/wordpress-tests-lib/includes/phpunit6-compat.php on line 18

This error is happening because Travis started ignoring the PHPUnit version that we install manually via Composer (https://github.com/woocommerce/woocommerce/blob/f7bc3fb85195df8f96c70d2846b0104ee224fef2/tests/bin/travis.sh#L6) and started using the PHPUnit version that is shipped with each of its PHP docker images. This means that for the docker images running PHP 7.2 and 7.3, PHPUnit 7 is used but the WordPress unit test framework is not compatible with PHPUnit 7 (see WordPress core ticket https://core.trac.wordpress.org/ticket/43218) and produces the error above. I believe that this is happening because Travis changed the directory where it installs composer global packages from `$HOME/.composer/` to `$HOME/.config/composer/` (travis-ci/travis-ci#7289 (comment)) and we add `$HOME/.composer/vendor/bin:$PATH` to the `$PATH`. So this commit simply updates the path in the line where we add it to the `$PATH`.

I tried to use `composer exec` instead of updating `$PATH` but that didn't work for PHP 5.2.
Copy link
Contributor

@peterfabian peterfabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks fine and the test finishes successfully.

@rodrigoprimo rodrigoprimo merged commit 62faa2d into woocommerce:master Dec 6, 2018
@rodrigoprimo rodrigoprimo deleted the fix/travis-php7 branch December 13, 2018 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants