Phpunit: Install on PHP 7.0 via composer does not work

Created on 6 Aug 2017  路  2Comments  路  Source: sebastianbergmann/phpunit

| Q | A
| --------------------| ---------------
| PHPUnit version | 6.3.0
| PHP version | 7.0
| Installation Method | Composer

I am running unit tests on Travis using multiple PHP versions. Specifically I want to test my code under PHP 7.0 which should be supported according to the PHP Unit homepage.

PHPUnit 6.3 is supported on PHP 7.0 and PHP 7.1.

The problem is that one of the PHPUnit dependencies (doctrine/instantiator) requires PHP 7.1 or greater.:

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for doctrine/instantiator 1.1.0 -> satisfiable by doctrine/instantiator[1.1.0].
    - doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.21) does not satisfy that requirement.
  Problem 2
    - doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.21) does not satisfy that requirement.
    - phpunit/phpunit-mock-objects 4.0.4 requires doctrine/instantiator ^1.0.5 -> satisfiable by doctrine/instantiator[1.1.0].
    - Installation request for phpunit/phpunit-mock-objects 4.0.4 -> satisfiable by phpunit/phpunit-mock-objects[4.0.4].

Travis build: https://travis-ci.org/fgrosse/PHPASN1/jobs/261533629

I will update my Travis file now and only test on PHP 7.1 and 7.2 (which works as expected) but I wanted to let you know that this issue exists.

Most helpful comment

Yes thanks, my mistake was that I added PHPUnit as requirement via composer on a machine running PHP7.1 and added the resulting composer.lock file to the repository. Removing that file (i.e. git rm --cached composer.lock) fixes the issue.

Alternatively I guess the composer.json could be updated to use a specific version of doctrine/instantiator which is compatible with an older PHP version. Then the lock file can again be versioned to give reproducible builds.

All 2 comments

Yes thanks, my mistake was that I added PHPUnit as requirement via composer on a machine running PHP7.1 and added the resulting composer.lock file to the repository. Removing that file (i.e. git rm --cached composer.lock) fixes the issue.

Alternatively I guess the composer.json could be updated to use a specific version of doctrine/instantiator which is compatible with an older PHP version. Then the lock file can again be versioned to give reproducible builds.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kunjalpopat picture kunjalpopat  路  4Comments

edyan picture edyan  路  4Comments

stephen-leavitt-sonyatv-com picture stephen-leavitt-sonyatv-com  路  4Comments

keradus picture keradus  路  4Comments

ezzatron picture ezzatron  路  3Comments