コード例 #1
0
 /**
  * @expectedException \Symfony\Component\Process\Exception\ProcessFailedException
  */
 public function testMustRunAllFail()
 {
     $helper = new ProcessHelper();
     $helper->setHelperSet(new HelperSet([new DebugFormatterHelper()]));
     /** @var Process[] $processes */
     $processes = [new Process('php -r "echo 42;"'), new Process('php -r "syntax error"'), new Process('php -r "echo 42;"')];
     $execute = new Execute(new NullOutput(), $helper);
     $execute->mustRunAll($processes);
 }
コード例 #2
0
ファイル: ProcessHelperTest.php プロジェクト: saj696/pipe
 public function testPassedCallbackIsExecuted()
 {
     $helper = new ProcessHelper();
     $helper->setHelperSet(new HelperSet(array(new DebugFormatterHelper())));
     $output = $this->getOutputStream(StreamOutput::VERBOSITY_NORMAL);
     $executed = false;
     $callback = function () use(&$executed) {
         $executed = true;
     };
     $helper->run($output, 'php -r "echo 42;"', null, $callback);
     $this->assertTrue($executed);
 }
コード例 #3
0
ファイル: Versioner.php プロジェクト: Anahkiasen/versioner
 /**
  * Execute a bash command.
  *
  * @param array $command
  * @param bool  $showOutput
  *
  * @return string
  */
 protected function execute(array $command, $showOutput = true)
 {
     $helper = new ProcessHelper();
     $helper->setHelperSet(new HelperSet(['debug_formatter' => new DebugFormatterHelper()]));
     // Compute new verbosity
     $previousVerbosity = $this->output->getVerbosity();
     $verbosity = $showOutput ? OutputInterface::VERBOSITY_DEBUG : OutputInterface::VERBOSITY_QUIET;
     // Execute command with defined verbosity
     $this->output->setVerbosity($verbosity);
     $process = $helper->run($this->output, $command);
     $this->output->setVerbosity($previousVerbosity);
     return $process->getOutput();
 }