Phpunit: incompatibility with PHP_Timer

Created on 13 Feb 2018  ·  3Comments  ·  Source: sebastianbergmann/phpunit

| Q | A
| --------------------| ---------------
| PHPUnit version | ~4.7.0 \|\| ~5.0.0 \|\| ~5.1.0 \|\| ~5.2.0
| PHP version | not related
| Installation Method | composer

PHP Timer v2 has been released. It is incompatible with mentioned PHPUnit, as PHPUnit with given version requires... >= 1 instead of ^1. For that, any new installation of that PHPUnit (in legacy project) will crash during execution with:
https://travis-ci.org/PHPUnitGoodPractices/Traits/jobs/341148960#L978

PHP Fatal error: Uncaught Error: Class 'PHP_Timer' not found in /home/travis/build/PHPUnitGoodPractices/Traits/vendor/phpunit/phpunit/src/Framework/TestResult.php:577

It will hit especially legacy PHP projects that cannot afford upgrading PHPUnit directly.

Yes, I do know that this will be taken as issue of not-maintained version and for that could be closed out of the box, yet it's in the end issue that php-timer major has been just released.

Most helpful comment

Solution for sad users of affected legacy PHPUnit versions:

add to your composer.json:

    "conflict": {
        "phpunit/php-timer": ">=2",
    }

this will basically make PHPUnit reuirement of php-timer to be ^1, like it is in other PHPUnit versions

All 3 comments

Solution for sad users of affected legacy PHPUnit versions:

add to your composer.json:

    "conflict": {
        "phpunit/php-timer": ">=2",
    }

this will basically make PHPUnit reuirement of php-timer to be ^1, like it is in other PHPUnit versions

PHPUnit 4.7 unfortunately has "phpunit/php-timer": ">=1.0.6" in its composer.json. However, PHPUnit 4.7 was superseded by PHPUnit 4.8 long ago. There is no reason not to update from PHPUnit 4.7 to PHPUnit 4.8. PHPUnit 4.8 has "phpunit/php-timer": "^1.0.6" in its composer.json.

You also mention PHPUnit 5.0, PHPUnit 5.1, and PHPUnit 5.2. All these versions have "phpunit/php-timer": "^1.0.6" in their composer.json.

What do you expect me to do here? Release a new version of PHPUnit 4.7 that has an updated composer.json? Sorry, but that won't happen. The solution you provided in https://github.com/sebastianbergmann/phpunit/issues/3008#issuecomment-365430405 should be good enough. Of course, the right solution would be to update to at least PHPUnit 4.8 or use a PHAR of PHPUnit 4.7.

You also mention PHPUnit 5.0, PHPUnit 5.1, and PHPUnit 5.2. All these versions have "phpunit/php-timer": "^1.0.6" in their composer.json.

no, 5.2.x-dev has phpunit/php-timer: ^1.0.6,
but last stable release of 5.2,
5.2.12 has phpunit/php-timer: >=1.0.6
for that 5.0.x, 5.1.x and 5.2.x are also affected.

PHP Timer has just been release, the release fact brought issue to legacy PHPUnit that I hit hard at my company and side projects, so purpose of this thread was to raise issue (so it could be found by users who also hit it) and provide possible workaround.

As I said in initial post, I don't expect new release of phpunit 4/5. Thanks!

Was this page helpful?
0 / 5 - 0 ratings