mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Collect solver problems in Problem objects with human readable output.
This commit is contained in:
parent
2249dd0548
commit
2c87fe5a22
6 changed files with 230 additions and 86 deletions
|
@ -40,9 +40,9 @@ class RequestTest extends TestCase
|
|||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('packages' => array($foo), 'cmd' => 'install', 'packageName' => 'foo'),
|
||||
array('packages' => array($bar), 'cmd' => 'install', 'packageName' => 'bar'),
|
||||
array('packages' => array($foobar), 'cmd' => 'remove', 'packageName' => 'foobar'),
|
||||
array('packages' => array($foo), 'cmd' => 'install', 'packageName' => 'foo', 'constraint' => null),
|
||||
array('packages' => array($bar), 'cmd' => 'install', 'packageName' => 'bar', 'constraint' => null),
|
||||
array('packages' => array($foobar), 'cmd' => 'remove', 'packageName' => 'foobar', 'constraint' => null),
|
||||
),
|
||||
$request->getJobs());
|
||||
}
|
||||
|
@ -63,11 +63,11 @@ class RequestTest extends TestCase
|
|||
$pool->addRepository($repo2);
|
||||
|
||||
$request = new Request($pool);
|
||||
$request->install('foo', $this->getVersionConstraint('=', '1'));
|
||||
$request->install('foo', $constraint = $this->getVersionConstraint('=', '1'));
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('packages' => array($foo1, $foo2), 'cmd' => 'install', 'packageName' => 'foo'),
|
||||
array('packages' => array($foo1, $foo2), 'cmd' => 'install', 'packageName' => 'foo', 'constraint' => $constraint),
|
||||
),
|
||||
$request->getJobs()
|
||||
);
|
||||
|
|
|
@ -59,13 +59,15 @@ class SolverTest extends TestCase
|
|||
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
||||
$this->reposComplete();
|
||||
|
||||
$this->request->install('B');
|
||||
$this->request->install('B', $this->getVersionConstraint('=', '1'));
|
||||
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not resolve in exception.');
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
} catch (SolverProblemsException $e) {
|
||||
// TODO assert problem properties
|
||||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
$this->assertEquals('The requested package "b" with constraint == 1.0.0.0 could not be found.', (string) $problems[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,8 +591,10 @@ class SolverTest extends TestCase
|
|||
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not resolve in exception.');
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
} catch (SolverProblemsException $e) {
|
||||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
// TODO assert problem properties
|
||||
}
|
||||
}
|
||||
|
@ -610,8 +614,10 @@ class SolverTest extends TestCase
|
|||
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not resolve in exception.');
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
} catch (SolverProblemsException $e) {
|
||||
$problems = $e->getProblems();
|
||||
$this->assertEquals(1, count($problems));
|
||||
// TODO assert problem properties
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue