Пример #1
0
 public function testPrettyString()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($p1 = $this->getPackage('foo', '2.1'));
     $repo->addPackage($p2 = $this->getPackage('baz', '1.1'));
     $this->pool->addRepository($repo);
     $rule = new Rule(array($p1->getId(), -$p2->getId()), 'job1', null);
     $this->assertEquals('(don\'t install baz 1.1|install foo 2.1)', $rule->getPrettyString($this->pool));
 }
Пример #2
0
 /**
  * @param Rule $why
  */
 private function disableProblem(Rule $why)
 {
     $job = $why->getJob();
     if (!$job) {
         $why->disable();
         return;
     }
     // disable all rules of this job
     foreach ($this->rules as $rule) {
         /** @var Rule $rule */
         if ($job === $rule->getJob()) {
             $rule->disable();
         }
     }
 }
Пример #3
0
 private function selectAndInstall($level, array $decisionQueue, $disableRules, Rule $rule)
 {
     $literals = $this->policy->selectPreferedPackages($this->pool, $this->installedMap, $decisionQueue, $rule->getRequiredPackage());
     $selectedLiteral = array_shift($literals);
     if (count($literals)) {
         $this->branches[] = array($literals, $level);
     }
     return $this->setPropagateLearn($level, $selectedLiteral, $disableRules, $rule);
 }
Пример #4
0
 private function selectAndInstall($level, array $decisionQueue, $disableRules, Rule $rule)
 {
     // choose best package to install from decisionQueue
     $literals = $this->policy->selectPreferredPackages($this->pool, $this->installedMap, $decisionQueue, $rule->getRequiredPackage());
     $selectedLiteral = array_shift($literals);
     // if there are multiple candidates, then branch
     if (count($literals)) {
         $this->branches[] = array($literals, $level);
     }
     return $this->setPropagateLearn($level, $selectedLiteral, $disableRules, $rule);
 }
Пример #5
0
 public function testToString()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($p1 = $this->getPackage('foo', '2.1'));
     $repo->addPackage($p2 = $this->getPackage('baz', '1.1'));
     $this->pool->addRepository($repo);
     $rule = new Rule($this->pool, array($p1->getId(), -$p2->getId()), 'job1', null);
     $this->assertEquals('(-baz-1.1.0.0|+foo-2.1.0.0)', $rule->__toString());
 }
Пример #6
0
 /**
  * Put watch2 on rule's literal with highest level
  */
 private function watch2OnHighest(Rule $rule)
 {
     $literals = $rule->getLiterals();
     // if there are only 2 elements, both are being watched anyway
     if ($literals < 3) {
         return;
     }
     $watchLevel = 0;
     foreach ($literals as $literal) {
         $level = abs($this->decisionMap[$literal->getPackageId()]);
         if ($level > $watchLevel) {
             $rule->watch2 = $literal->getId();
             $watchLevel = $level;
         }
     }
 }
Пример #7
0
 public function testToString()
 {
     $literal = new Literal($this->getPackage('foo', '2.1'), true);
     $literal2 = new Literal($this->getPackage('baz', '1.1'), false);
     $rule = new Rule(array($literal, $literal2), 'job1', null);
     $this->assertEquals('(-baz-1.1.0.0|+foo-2.1.0.0)', $rule->__toString());
 }