コード例 #1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $satisFile = $input->getArgument('satis');
     if (false === file_exists($satisFile)) {
         throw new \InvalidArgumentException(sprintf('required file does not exists: "%s"', $satisFile), 1446115325);
     }
     $composerFile = $input->getArgument('composer');
     if (false === file_exists($composerFile)) {
         throw new \InvalidArgumentException(sprintf('required file does not exists: "%s"', $composerFile), 1446115336);
     }
     $satis = json_decode(file_get_contents($satisFile));
     if (json_last_error() !== JSON_ERROR_NONE) {
         throw new \RuntimeException(sprintf('An error has occurred while decoding "%s". Error code: %s. Error message: "%s".', $satisFile, json_last_error(), json_last_error_msg()), 1447257223);
     }
     $composer = json_decode(file_get_contents($composerFile));
     if (json_last_error() !== JSON_ERROR_NONE) {
         throw new \RuntimeException(sprintf('An error has occurred while decoding "%s". Error code: %s. Error message: "%s".', $composerFile, json_last_error(), json_last_error_msg()), 1447257260);
     }
     $builder = new SatisBuilder($composer, $satis);
     if ($input->getOption('reset-requirements')) {
         $builder->resetSatisRequires();
     }
     if ($input->getOption('require-dependencies')) {
         $builder->setRequireDependencies($input->getOption('require-dependencies'));
     }
     if ($input->getOption('require-dev-dependencies')) {
         $builder->setRequireDevDependencies($input->getOption('require-dependencies'));
     }
     if ($input->getOption('add-requirements')) {
         $builder->addRequiresFromComposer();
     }
     if ($input->getOption('add-dev-requirements')) {
         $builder->addDevRequiresFromComposer();
     }
     file_put_contents($satisFile, json_encode($builder->build(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
 }
コード例 #2
0
 /**
  * @test
  */
 public function shouldNotRequireDependencies()
 {
     $composer = $this->getFixture('composer.multiple.json');
     $satis = new \stdClass();
     $builder = new SatisBuilder($composer, $satis);
     $builder->setRequireDependencies(false);
     $this->assertFalse($builder->build()->{'require-dependencies'});
 }