Sfoglia il codice sorgente

Create an impossible rule when trying to install something that doesn't exist.

The rule isn't acted upon yet (hence the incomplete test) but it is there as a reminder that this case needs to be handled.
Volker Dusch 13 anni fa
parent
commit
eafe13d5a5

+ 6 - 0
src/Composer/DependencyResolver/Solver.php

@@ -964,6 +964,12 @@ class Solver
 
 
         foreach ($this->jobs as $job) {
+            if (empty($job['packages']) && $job['cmd'] == 'install') {
+                $this->addRule(
+                    RuleSet::TYPE_JOB,
+                    $this->createImpossibleRule(static::RULE_JOB_INSTALL, $job)
+                );
+            }
             foreach ($job['packages'] as $package) {
                 switch ($job['cmd']) {
                     case 'install':

+ 16 - 0
tests/Composer/Test/DependencyResolver/SolverTest.php

@@ -55,6 +55,22 @@ class SolverTest extends TestCase
         ));
     }
 
+    public function testInstallNonExistingPackageFails()
+    {
+        $this->repo->addPackage($this->getPackage('A', '1.0'));
+        $this->reposComplete();
+
+        $this->request->install('B');
+
+        try {
+            $transaction = $this->solver->solve($this->request);
+            $this->markTestIncomplete('Reporting this failure is not implemented/working yet');
+            //$this->fail('Unsolvable conflict did not resolve in exception.');
+        } catch (SolverProblemsException $e) {
+            // @todo: assert problem properties
+        }
+    }
+
     public function testSolverInstallWithDeps()
     {
         $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));