mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
Improve error reporting of solver issues, refs #7779
Fixes #8525 Fixes #6513
This commit is contained in:
parent
f611c641db
commit
3fc7e10c5c
34 changed files with 482 additions and 223 deletions
|
@ -143,12 +143,18 @@ class RuleSetTest extends TestCase
|
|||
$p = $this->getPackage('foo', '2.1'),
|
||||
));
|
||||
|
||||
$repositorySetMock = $this->getMockBuilder('Composer\Repository\RepositorySet')->disableOriginalConstructor()->getMock();
|
||||
$repositorySetMock->expects($this->any())
|
||||
->method('getPool')
|
||||
->willReturn($pool);
|
||||
$requestMock = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$ruleSet = new RuleSet;
|
||||
$literal = $p->getId();
|
||||
$rule = new GenericRule(array($literal), Rule::RULE_ROOT_REQUIRE, array('packageName' => 'foo/bar', 'constraint' => null));
|
||||
|
||||
$ruleSet->add($rule, RuleSet::TYPE_REQUEST);
|
||||
|
||||
$this->assertContains('REQUEST : No package found to satisfy root composer.json require foo/bar', $ruleSet->getPrettyString($pool));
|
||||
$this->assertContains('REQUEST : No package found to satisfy root composer.json require foo/bar', $ruleSet->getPrettyString($repositorySetMock, $requestMock));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,8 +99,14 @@ class RuleTest extends TestCase
|
|||
$p2 = $this->getPackage('baz', '1.1'),
|
||||
));
|
||||
|
||||
$repositorySetMock = $this->getMockBuilder('Composer\Repository\RepositorySet')->disableOriginalConstructor()->getMock();
|
||||
$repositorySetMock->expects($this->any())
|
||||
->method('getPool')
|
||||
->willReturn($pool);
|
||||
$requestMock = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$rule = new GenericRule(array($p1->getId(), -$p2->getId()), Rule::RULE_PACKAGE_REQUIRES, new Link('baz', 'foo'));
|
||||
|
||||
$this->assertEquals('baz 1.1 relates to foo -> satisfiable by foo[2.1].', $rule->getPrettyString($pool));
|
||||
$this->assertEquals('baz 1.1 relates to foo -> satisfiable by foo[2.1].', $rule->getPrettyString($repositorySetMock, $requestMock));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class SolverTest extends TestCase
|
|||
$problems = $e->getProblems();
|
||||
$this->assertCount(1, $problems);
|
||||
$this->assertEquals(2, $e->getCode());
|
||||
$this->assertEquals("\n - The requested package b could not be found in any version, there may be a typo in the package name.", $problems[0]->getPrettyString());
|
||||
$this->assertEquals("\n - Root composer.json requires b, it could not be found in any version, there may be a typo in the package name.", $problems[0]->getPrettyString($this->repoSet, $this->request));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -682,13 +682,7 @@ class SolverTest extends TestCase
|
|||
$msg = "\n";
|
||||
$msg .= " Problem 1\n";
|
||||
$msg .= " - Root composer.json requires 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";
|
||||
$msg .= " - The package is not available in a stable-enough version according to your minimum-stability setting\n";
|
||||
$msg .= " see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.\n";
|
||||
$msg .= " - It's a private package and you forgot to add a custom repository to find it\n\n";
|
||||
$msg .= "Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
|
||||
$msg .= " - A 1.0 requires b >= 2.0 -> found B[1.0] but it does not match your constraint.\n";
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -895,7 +889,7 @@ class SolverTest extends TestCase
|
|||
|
||||
protected function createSolver()
|
||||
{
|
||||
$this->solver = new Solver($this->policy, $this->repoSet->createPool($this->request), new NullIO());
|
||||
$this->solver = new Solver($this->policy, $this->repoSet->createPool($this->request), new NullIO(), $this->repoSet);
|
||||
}
|
||||
|
||||
protected function checkSolverResult(array $expected)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue