/**
  * @expectedException \SensioLabs\Melody\Exception\ConfigException
  */
 public function testLoadWithoutWrongData()
 {
     $filename = sprintf('%s/%s', sys_get_temp_dir(), uniqid());
     if (file_exists($filename)) {
         unlink($filename);
     }
     file_put_contents($filename, 'foo: *bar');
     try {
         $repositpory = new UserConfigurationRepository($filename);
         $repositpory->load();
         unlink($filename);
     } catch (\Exception $e) {
         unlink($filename);
         throw $e;
     }
 }
Beispiel #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $melody = new Melody();
     $configRepository = new UserConfigurationRepository();
     $userConfig = $configRepository->load();
     $processHelper = $this->getHelperSet()->get('process');
     $cliExecutor = function (Process $process, $verbose) use($output, $processHelper) {
         if ($verbose) {
             // print debugging output for the build process
             $processHelper->mustRun($output, $process);
         } else {
             $callback = function ($type, $text) use($output) {
                 if ($type == 'out' && $output instanceof ConsoleOutputInterface) {
                     $output = $output->getErrorOutput();
                 }
                 $output->write($text);
             };
             return $process->run($callback);
         }
     };
     $runConfiguration = new RunConfiguration($input->getOption('no-cache'), $input->getOption('prefer-source'), $input->getOption('trust'));
     $script = $input->getArgument('script');
     $arguments = $input->getArgument('arguments');
     while (true) {
         try {
             $melody->run($script, $arguments, $runConfiguration, $userConfig, $cliExecutor);
             return 0;
         } catch (TrustException $e) {
             if (false === $this->confirmTrust($e->getResource(), $input, $output)) {
                 $output->writeln('<error>Operation aborted by the user.</error>');
                 return 1;
             }
             $userConfig->addTrustedSignature($e->getResource()->getSignature());
             $configRepository->save($userConfig);
         }
     }
 }