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