/**
  * @dataProvider dataProviderTestDiff
  * @param $lockOne
  * @param $lockTwo
  */
 public function testDiff($lockOne, $lockTwo, $expected, $exception = '')
 {
     if ($exception) {
         $this->setExpectedExceptionRegExp($exception);
     }
     $helper = new ComposerHelper();
     $actual = $helper->diff($lockOne, $lockTwo);
     $this->assertEquals($expected, $actual);
 }
Exemple #2
0
 /**
  * @param RepositoryModel $model
  * @return array
  */
 protected function findVendorsForUpdate(RepositoryModel $model)
 {
     $fileSystem = new Filesystem();
     $fileSystem->copy($model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK, $model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK_CONFLICT, true);
     $model->getProvider()->run('checkout', ['--theirs', ComposerHelper::COMPOSER_LOCK], $this->isDryRun(), false);
     $theirLock = file_get_contents($model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK);
     $fileSystem->copy($model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK_CONFLICT, $model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK, true);
     $model->getProvider()->run('checkout', ['--ours', ComposerHelper::COMPOSER_LOCK], $this->isDryRun(), false);
     $oursLock = file_get_contents($model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK);
     $fileSystem->rename($model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK_CONFLICT, $model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_LOCK, true);
     $helper = new ComposerHelper();
     $vendorsForUpdate = $helper->diff($theirLock, $oursLock);
     $composerJson = file_get_contents($model->getAbsolutePath() . DIRECTORY_SEPARATOR . ComposerHelper::COMPOSER_JSON);
     $vendors = $helper->extractAllVendors($composerJson);
     $vendorsForUpdate = array_intersect($vendorsForUpdate, $vendors);
     return $vendorsForUpdate;
 }