function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, PhpCsFixerFormatter $formatter) { $grumPHP->getTaskConfiguration('phpcsfixer')->willReturn(array()); $formatter->format(Argument::any())->willReturn(''); $formatter->formatSuggestion(Argument::any())->willReturn(''); $formatter->formatErrorMessage(Argument::cetera())->willReturn(''); $this->beConstructedWith($grumPHP, $processBuilder, $formatter); }
/** * @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); }