run() public method

public run ( array $processes )
$processes array
Esempio n. 1
0
 /**
  * @param ContextInterface           $context
  * @param ProcessArgumentsCollection $arguments
  * @param FilesCollection            $files
  *
  * @return TaskResult
  */
 protected function runOnChangedFiles(ContextInterface $context, ProcessArgumentsCollection $arguments, FilesCollection $files)
 {
     $hasErrors = false;
     $messages = [];
     $suggestions = [];
     foreach ($files as $file) {
         $fileArguments = new ProcessArgumentsCollection($arguments->getValues());
         $fileArguments->add($file);
         $processes[] = $this->processBuilder->buildProcess($fileArguments);
     }
     $this->processRunner->run($processes);
     foreach ($processes as $process) {
         if (!$process->isSuccessful()) {
             $hasErrors = true;
             $messages[] = $this->formatter->format($process);
             $suggestions[] = $this->formatter->formatSuggestion($process);
         }
     }
     if ($hasErrors) {
         $errorMessage = $this->formatter->formatErrorMessage($messages, $suggestions);
         return TaskResult::createFailed($this, $context, $errorMessage);
     }
     return TaskResult::createPassed($this, $context);
 }
Esempio n. 2
0
 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, AsyncProcessRunner $processRunner, Process $process, ContextInterface $context, PhpCsFixerFormatter $formatter)
 {
     $formatter->resetCounter()->shouldBeCalled();
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('php-cs-fixer')->willReturn($arguments);
     $processBuilder->buildProcess(Argument::type(ProcessArgumentsCollection::class))->willReturn($process);
     $processRunner->run(Argument::type('array'))->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file1.php', '.', 'file1.php')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }