Пример #1
0
 public function testGetConflictReturnModuleName()
 {
     $this->assertEquals(['C' => '0.1'], $this->packageInfo->getConflict('A'));
     $this->assertEquals([], $this->packageInfo->getConflict('B'));
     $this->assertEquals([], $this->packageInfo->getConflict('C'));
     $this->assertEquals(['C' => '0.1'], $this->packageInfo->getConflict('D'));
     $this->assertEquals([], $this->packageInfo->getConflict('E'));
 }
 /**
  * Check if two modules are conflicted and get the message for display
  *
  * @param string $moduleA
  * @param string $moduleB
  * @return string[]
  */
 private function getConflictMessages($moduleA, $moduleB)
 {
     $messages = [];
     $versionParser = new VersionParser();
     if (isset($this->packageInfo->getConflict($moduleB)[$moduleA]) && $this->packageInfo->getConflict($moduleB)[$moduleA] && $this->packageInfo->getVersion($moduleA)) {
         $constraintA = $versionParser->parseConstraints($this->packageInfo->getConflict($moduleB)[$moduleA]);
         $constraintB = $versionParser->parseConstraints($this->packageInfo->getVersion($moduleA));
         if ($constraintA->matches($constraintB)) {
             $messages[] = "{$moduleB} conflicts with current {$moduleA} version " . $this->packageInfo->getVersion($moduleA) . ' (version should not be ' . $this->packageInfo->getConflict($moduleB)[$moduleA] . ')';
         }
     }
     if (isset($this->packageInfo->getConflict($moduleA)[$moduleB]) && $this->packageInfo->getConflict($moduleA)[$moduleB] && $this->packageInfo->getVersion($moduleB)) {
         $constraintA = $versionParser->parseConstraints($this->packageInfo->getConflict($moduleA)[$moduleB]);
         $constraintB = $versionParser->parseConstraints($this->packageInfo->getVersion($moduleB));
         if ($constraintA->matches($constraintB)) {
             $messages[] = "{$moduleA} conflicts with current {$moduleB} version " . $this->packageInfo->getVersion($moduleA) . ' (version should not be ' . $this->packageInfo->getConflict($moduleA)[$moduleB] . ')';
         }
     }
     return $messages;
 }