简体   繁体   中英

I can't upgrade PHPUnit 5 with composer using PHP 5.6 on WAMP

I had PHPUnit v4.7 and I tried to go to v5. So why is code-coverage not installed and how do I fix it? I already tried removing the phpunit folder altogether. I am using the install command as in https://phpunit.de/getting-started/phpunit-5.html

This is my output:

c:\[path to]\composer require --dev phpunit/phpunit ^5
./composer.json has been updated
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpunit/phpunit 5 -> satisfiable by phpunit/phpunit[5.0.0].
    - Conclusion: don't install phpunit/php-code-coverage 2.2.4
    - phpunit/phpunit 5.0.0 requires phpunit/php-code-coverage ~3.0 -> satisfiable by phpunit/php-code-coverage[3.0.0, 3.0.1, 3.0.2, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.3.0, 3.3.1, 3.3.2, 3.3.3].
    - Can only install one of: phpunit/php-code-coverage[3.0.0, 2.2.4].
   ... <repeated with more versions>
    - Can only install one of: phpunit/php-code-coverage[3.3.3, 2.2.4].
    - Installation request for phpunit/php-code-coverage (locked at 2.2.4) -> satisfiable by phpunit/php-code-coverage[2.2.4].


Installation failed, reverting ./composer.json to its original content.

update: this is my composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.0.*",
        "illuminate/html": "^5.0",
        "adamwathan/bootforms": "@dev",
        "patricktalmadge/bootstrapper": "~5",
        "frozennode/administrator": "^5.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "^5",
        "laracasts/integrated": "^0.15.6"        
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Your phpunit/php-code-coverage is already locked at 2.2.4 (check the composer.lock which requires phpunit/phpunit ~4 (see: composer show -a phpunit/php-code-coverage 2.2.4 ), and you're trying to install phpunit/phpunit 5 .

Now, phpunit/phpunit 5.0.0 requires phpunit/php-code-coverage ~3.0 :

$ composer show -a phpunit/phpunit 5.0.0 | grep coverage
phpunit/php-code-coverage ~3.0

where your locked version is 2.2.4 , and you cannot have both ( 3.3.3 , 2.2.4 ).

To see why the specific package is locked, run:

composer why -t phpunit/php-code-coverage

Note: You may also add a version/constraint at the end.

So you can try to:

  • Update your existing packages along with all dependencies by:

     composer update --with-dependencies 
  • Update specific package which is failing by:

     composer update phpunit/php-code-coverage --with-dependencies 
  • Remove composer.lock and reinstall all your packages again by:

     composer install 

To see the current tree of dependencies, run:

composer show -t

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM