Fix tests and convert all package lists to Name[Versions] format
parent
201cde05be
commit
cc9dac8fe2
|
@ -172,11 +172,16 @@ class Problem
|
|||
|
||||
protected function getPackageList($packages)
|
||||
{
|
||||
return implode(', ', array_unique(array_map(function ($package) {
|
||||
return $package->getPrettyString();
|
||||
},
|
||||
$packages
|
||||
)));
|
||||
$prepared = array();
|
||||
foreach ($packages as $package) {
|
||||
$prepared[$package->getName()]['name'] = $package->getPrettyName();
|
||||
$prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion();
|
||||
}
|
||||
foreach ($prepared as $name => $package) {
|
||||
$prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
|
||||
}
|
||||
|
||||
return implode(', ', $prepared);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -194,7 +194,7 @@ class Rule
|
|||
$package1 = $this->pool->literalToPackage($this->literals[0]);
|
||||
$package2 = $this->pool->literalToPackage($this->literals[1]);
|
||||
|
||||
return $package1->getPrettyString().' conflicts with '.$package2->getPrettyString().'.';
|
||||
return $package1->getPrettyString().' conflicts with '.$this->formatPackagesUnique(array($package2)).'.';
|
||||
|
||||
case self::RULE_PACKAGE_REQUIRES:
|
||||
$literals = $this->literals;
|
||||
|
@ -208,14 +208,7 @@ class Rule
|
|||
|
||||
$text = $this->reasonData->getPrettyString($sourcePackage);
|
||||
if ($requires) {
|
||||
$requireText = array();
|
||||
foreach ($requires as $require) {
|
||||
$requireText[$require->getName()][] = $require->getPrettyVersion();
|
||||
}
|
||||
foreach ($requireText as $name => $versions) {
|
||||
$requireText[$name] = $name.'['.implode(', ', $versions).']';
|
||||
}
|
||||
$text .= ' -> satisfiable by '.implode(', ', $requireText);
|
||||
$text .= ' -> satisfiable by ' . $this->formatPackagesUnique($requires) . '.';
|
||||
} else {
|
||||
$targetName = $this->reasonData->getTarget();
|
||||
|
||||
|
@ -242,14 +235,7 @@ class Rule
|
|||
case self::RULE_INSTALLED_PACKAGE_OBSOLETES:
|
||||
return $ruleText;
|
||||
case self::RULE_PACKAGE_SAME_NAME:
|
||||
$text = "Can only install one of: ";
|
||||
|
||||
$packages = array();
|
||||
foreach ($this->literals as $i => $literal) {
|
||||
$packages[] = $this->pool->literalToPackage($literal)->getPrettyString();
|
||||
}
|
||||
|
||||
return $text.implode(', ', $packages).'.';
|
||||
return 'Can only install one of: ' . $this->formatPackagesUnique($this->literals) . '.';
|
||||
case self::RULE_PACKAGE_IMPLICIT_OBSOLETES:
|
||||
return $ruleText;
|
||||
case self::RULE_LEARNED:
|
||||
|
@ -259,6 +245,23 @@ class Rule
|
|||
}
|
||||
}
|
||||
|
||||
protected function formatPackagesUnique(array $packages)
|
||||
{
|
||||
$prepared = array();
|
||||
foreach ($packages as $package) {
|
||||
if (!is_object($package)) {
|
||||
$package = $this->pool->literalToPackage($package);
|
||||
}
|
||||
$prepared[$package->getName()]['name'] = $package->getPrettyName();
|
||||
$prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion();
|
||||
}
|
||||
foreach ($prepared as $name => $package) {
|
||||
$prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
|
||||
}
|
||||
|
||||
return implode(', ', $prepared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a rule as a string of the format (Literal1|Literal2|...)
|
||||
*
|
||||
|
|
|
@ -675,9 +675,9 @@ class SolverTest extends TestCase
|
|||
|
||||
$msg = "\n";
|
||||
$msg .= " Problem 1\n";
|
||||
$msg .= " - Installation request for a -> satisfiable by A 1.0.\n";
|
||||
$msg .= " - B 1.0 conflicts with A 1.0.\n";
|
||||
$msg .= " - Installation request for b -> satisfiable by B 1.0.\n";
|
||||
$msg .= " - Installation request for a -> satisfiable by A[1.0].\n";
|
||||
$msg .= " - B 1.0 conflicts with A[1.0].\n";
|
||||
$msg .= " - Installation request for b -> satisfiable by B[1.0].\n";
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$msg = "\n";
|
||||
$msg .= " Problem 1\n";
|
||||
$msg .= " - Installation request for a -> satisfiable by A 1.0.\n";
|
||||
$msg .= " - Installation request for a -> satisfiable by A[1.0].\n";
|
||||
$msg .= " - A 1.0 requires b >= 2.0 -> no matching package found.\n\n";
|
||||
$msg .= "Potential causes:\n";
|
||||
$msg .= " - A typo in the package name\n";
|
||||
|
@ -750,12 +750,12 @@ class SolverTest extends TestCase
|
|||
|
||||
$msg = "\n";
|
||||
$msg .= " Problem 1\n";
|
||||
$msg .= " - C 1.0 requires d >= 1.0 -> satisfiable by D 1.0.\n";
|
||||
$msg .= " - D 1.0 requires b < 1.0 -> satisfiable by B 0.9.\n";
|
||||
$msg .= " - B 1.0 requires c >= 1.0 -> satisfiable by C 1.0.\n";
|
||||
$msg .= " - Can only install one of: B 0.9, B 1.0.\n";
|
||||
$msg .= " - A 1.0 requires b >= 1.0 -> satisfiable by B 1.0.\n";
|
||||
$msg .= " - Installation request for a -> satisfiable by A 1.0.\n";
|
||||
$msg .= " - C 1.0 requires d >= 1.0 -> satisfiable by D[1.0].\n";
|
||||
$msg .= " - D 1.0 requires b < 1.0 -> satisfiable by B[0.9].\n";
|
||||
$msg .= " - B 1.0 requires c >= 1.0 -> satisfiable by C[1.0].\n";
|
||||
$msg .= " - Can only install one of: B[0.9, 1.0].\n";
|
||||
$msg .= " - A 1.0 requires b >= 1.0 -> satisfiable by B[1.0].\n";
|
||||
$msg .= " - Installation request for a -> satisfiable by A[1.0].\n";
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue