From 94daeca57b87da6762116bd85861adc722bfa0df Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Fri, 5 Feb 2016 11:39:14 +0100 Subject: [PATCH] add test and adjust rule error message --- src/Composer/DependencyResolver/Rule.php | 4 +- .../installer/github-issues-4319.test | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/Composer/Test/Fixtures/installer/github-issues-4319.test diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index 13bbb7e09..32546fd27 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -207,7 +207,9 @@ class Rule } elseif ($targetName === 'hhvm') { $text .= ' -> you are running this with PHP and not HHVM.'; } else { - $text .= ' -> your PHP version ('. phpversion() .') or value of "config.platform.php" in composer.json does not satisfy that requirement.'; + $available = $pool->whatProvides($targetName); + $version = count($available) ? $available[0]->getPrettyVersion() : phpversion(); + $text .= ' -> your PHP version or "config.platform.php" value ('.$version.') does not satisfy that requirement.'; } } elseif (0 === strpos($targetName, 'ext-')) { // handle php extensions diff --git a/tests/Composer/Test/Fixtures/installer/github-issues-4319.test b/tests/Composer/Test/Fixtures/installer/github-issues-4319.test new file mode 100644 index 000000000..5bfc17af6 --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/github-issues-4319.test @@ -0,0 +1,45 @@ +--TEST-- + +See Github issue #4319 ( github.com/composer/composer/issues/4319 ). + +Present a clear error message when config.platform.php version results in a conflict rule. + +--CONDITION-- +!defined('HHVM_VERSION') + +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "a", "version": "1.0.0", "require": { "php": "5.5" } } + ] + } + ], + "require": { + "a": "~1.0" + }, + "config": { + "platform": { + "php": "5.3" + } + } +} + +--RUN-- +install + +--EXPECT-OUTPUT-- +Loading composer repositories with package information +Installing dependencies (including require-dev) +Your requirements could not be resolved to an installable set of packages. + + Problem 1 + - Installation request for a ~1.0 -> satisfiable by a[1.0.0]. + - a 1.0.0 requires php 5.5 -> your PHP version or "config.platform.php" value (5.3) does not satisfy that requirement. + +--EXPECT-- + +--EXPECT-EXIT-CODE-- +2