mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Make problem report messages more readable
Added pretty strings to constraints
This commit is contained in:
parent
4bbb168d44
commit
cc7632489d
14 changed files with 187 additions and 40 deletions
|
@ -66,7 +66,7 @@ class SolverTest extends TestCase
|
|||
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
||||
$this->reposComplete();
|
||||
|
||||
$this->request->install('B', $this->getVersionConstraint('=', '1'));
|
||||
$this->request->install('B', $this->getVersionConstraint('==', '1'));
|
||||
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
|
@ -74,7 +74,7 @@ class SolverTest extends TestCase
|
|||
} catch (SolverProblemsException $e) {
|
||||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
$this->assertEquals('The requested package b == 1.0.0.0 could not be found.', (string) $problems[0]);
|
||||
$this->assertEquals('The requested package b == 1 could not be found.', $problems[0]->getPrettyString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,13 @@ class SolverTest extends TestCase
|
|||
} catch (SolverProblemsException $e) {
|
||||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
// TODO assert problem properties
|
||||
|
||||
$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";
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,6 +671,56 @@ class SolverTest extends TestCase
|
|||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
// TODO assert problem properties
|
||||
|
||||
$msg = "\n";
|
||||
$msg .= " Problem 1\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";
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testRequireMismatchException()
|
||||
{
|
||||
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
||||
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
||||
$this->repo->addPackage($packageB2 = $this->getPackage('B', '0.9'));
|
||||
$this->repo->addPackage($packageC = $this->getPackage('C', '1.0'));
|
||||
$this->repo->addPackage($packageD = $this->getPackage('D', '1.0'));
|
||||
|
||||
$packageA->setRequires(array(
|
||||
new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
||||
));
|
||||
$packageB->setRequires(array(
|
||||
new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
||||
));
|
||||
$packageC->setRequires(array(
|
||||
new Link('C', 'D', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
||||
));
|
||||
$packageD->setRequires(array(
|
||||
new Link('D', 'B', $this->getVersionConstraint('<', '1.0'), 'requires'),
|
||||
));
|
||||
|
||||
$this->reposComplete();
|
||||
|
||||
$this->request->install('A');
|
||||
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
} catch (SolverProblemsException $e) {
|
||||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
|
||||
$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";
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue