Fix update, fixes #125
parent
5c8eb355ce
commit
8cfbf9e198
|
@ -86,21 +86,13 @@ EOT
|
|||
$request = new Request($pool);
|
||||
if ($update) {
|
||||
$output->writeln('<info>Updating dependencies.</info>');
|
||||
$listedPackages = array();
|
||||
$installedPackages = $installedRepo->getPackages();
|
||||
$links = $this->collectLinks($input, $composer->getPackage());
|
||||
|
||||
foreach ($links as $link) {
|
||||
$listedPackages[] = $link->getTarget();
|
||||
|
||||
foreach ($installedPackages as $package) {
|
||||
if ($package->getName() === $link->getTarget()) {
|
||||
$constraint = new VersionConstraint('=', $package->getVersion());
|
||||
if ($link->getConstraint()->matches($constraint)) {
|
||||
continue 2;
|
||||
}
|
||||
// TODO this should just update to the exact version (once constraints are available on update, see #125)
|
||||
$request->remove($package->getName(), $constraint);
|
||||
$request->update($package->getName(), new VersionConstraint('=', $package->getVersion()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,40 @@ class SolverTest extends TestCase
|
|||
$this->checkSolverResult(array());
|
||||
}
|
||||
|
||||
public function testSolverUpdateConstrained()
|
||||
{
|
||||
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
||||
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.2'));
|
||||
$this->repo->addPackage($this->getPackage('A', '2.0'));
|
||||
$this->reposComplete();
|
||||
|
||||
$this->request->install('A', new VersionConstraint('<', '2.0.0.0'));
|
||||
$this->request->update('A');
|
||||
|
||||
$this->checkSolverResult(array(array(
|
||||
'job' => 'update',
|
||||
'from' => $packageA,
|
||||
'to' => $newPackageA,
|
||||
)));
|
||||
}
|
||||
|
||||
public function testSolverUpdateFullyConstrained()
|
||||
{
|
||||
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
||||
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.2'));
|
||||
$this->repo->addPackage($this->getPackage('A', '2.0'));
|
||||
$this->reposComplete();
|
||||
|
||||
$this->request->install('A', new VersionConstraint('<', '2.0.0.0'));
|
||||
$this->request->update('A', new VersionConstraint('=', '1.0.0.0'));
|
||||
|
||||
$this->checkSolverResult(array(array(
|
||||
'job' => 'update',
|
||||
'from' => $packageA,
|
||||
'to' => $newPackageA,
|
||||
)));
|
||||
}
|
||||
|
||||
public function testSolverAllJobs()
|
||||
{
|
||||
$this->repoInstalled->addPackage($packageD = $this->getPackage('D', '1.0'));
|
||||
|
|
Loading…
Reference in New Issue