buildProcess() public method

public buildProcess ( ProcessArgumentsCollection $arguments ) : Process
$arguments GrumPHP\Collection\ProcessArgumentsCollection
return Symfony\Component\Process\Process
コード例 #1
0
ファイル: PhpcsFormatter.php プロジェクト: phpro/grumphp
 /**
  * @param ProcessArgumentsCollection $defaultArguments
  * @param ProcessBuilder $processBuilder
  * @return string
  */
 public function formatErrorMessage(ProcessArgumentsCollection $defaultArguments, ProcessBuilder $processBuilder)
 {
     if (empty($this->suggestedFiles)) {
         return '';
     }
     $defaultArguments->addArgumentArray('%s', $this->suggestedFiles);
     return sprintf('%sYou can fix some errors by running following command:%s', PHP_EOL . PHP_EOL, PHP_EOL . $processBuilder->buildProcess($defaultArguments)->getCommandLine());
 }
コード例 #2
0
ファイル: ConflictSpec.php プロジェクト: phpro/grumphp
 function it_lists_files_with_merge_conflicts(ProcessBuilder $processBuilder, ContextInterface $context, Process $process)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('git')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file1.php', '.', 'file1.php')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(true);
 }
コード例 #3
0
ファイル: BehatSpec.php プロジェクト: aaa2000/grumphp
 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('behat')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('test.php', '.', 'test.php'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
コード例 #4
0
ファイル: PhpcsFormatterSpec.php プロジェクト: phpro/grumphp
 function it_formats_phpcs_json_output_for_multiple_files(Process $process, ProcessBuilder $processBuilder)
 {
     $json = $this->parseJson(['/var/www/Classes/Command/CacheCommandController.php' => ['messages' => [['fixable' => true]]], '/var/www/Classes/Command/DebugCommandController.php' => ['messages' => [['fixable' => false]]]]);
     $arguments = new ProcessArgumentsCollection(['phpcbf']);
     $process->getOutput()->willReturn($this->getExampleData() . $json);
     $this->format($process)->shouldBe($this->getExampleData());
     $this->getSuggestedFilesFromJson(json_decode($json, true))->shouldBe(['/var/www/Classes/Command/CacheCommandController.php']);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->getCommandLine()->willReturn("'phpcbf' '--standard=PSR2' '--ignore=spec/*Spec.php,test/*.php' '/var/www/Classes/Command/CacheCommandController.php'");
     $this->formatErrorMessage($arguments, $processBuilder)->shouldBe(sprintf('%sYou can fix some errors by running following command:%s', PHP_EOL . PHP_EOL, PHP_EOL . "'phpcbf' '--standard=PSR2' '--ignore=spec/*Spec.php,test/*.php' '/var/www/Classes/Command/CacheCommandController.php'"));
 }
コード例 #5
0
 function it_throws_an_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('security-checker')->willReturn($arguments);
     $processBuilder->buildProcess(Argument::type('GrumPHP\\Collection\\ProcessArgumentsCollection'))->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('composer.lock', '.', 'composer.lock'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
コード例 #6
0
ファイル: PhingSpec.php プロジェクト: phpro/grumphp
 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('phing')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('test.php', '.', 'test.php')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
コード例 #7
0
 function it_throws_exception_if_the_process_is_successfull(GrumPHP $grumPHP, ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $grumPHP->getTaskConfiguration('git_blacklist')->willReturn(array('keywords' => array('var_dump(')));
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('git')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file1.php', '.', 'file1.php'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
コード例 #8
0
ファイル: ComposerSpec.php プロジェクト: Big-Shark/grumphp
 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('composer')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('composer.json', '.', 'composer.json'))));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf('GrumPHP\\Runner\\TaskResultInterface');
     $result->isPassed()->shouldBe(false);
 }
コード例 #9
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);
 }
コード例 #10
0
ファイル: PhpCsFixerSpec.php プロジェクト: Big-Shark/grumphp
 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context, PhpCsFixerFormatter $formatter)
 {
     $formatter->resetCounter()->shouldBeCalled();
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('php-cs-fixer')->willReturn($arguments);
     $processBuilder->buildProcess(Argument::type('GrumPHP\\Collection\\ProcessArgumentsCollection'))->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file1.php', '.', 'file1.php'))));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf('GrumPHP\\Runner\\TaskResultInterface');
     $result->isPassed()->shouldBe(false);
 }
コード例 #11
0
ファイル: BlacklistSpec.php プロジェクト: phpro/grumphp
 function it_throws_exception_if_the_process_is_successfull(GrumPHP $grumPHP, ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $grumPHP->getTaskConfiguration('git_blacklist')->willReturn(['keywords' => ['var_dump(']]);
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('git')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file1.php', '.', 'file1.php')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
コード例 #12
0
ファイル: SecurityCheckerSpec.php プロジェクト: phpro/grumphp
 function it_throws_an_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('security-checker')->willReturn($arguments);
     $processBuilder->buildProcess(Argument::type(ProcessArgumentsCollection::class))->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('composer.lock', '.', 'composer.lock')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
コード例 #13
0
ファイル: ComposerSpec.php プロジェクト: phpro/grumphp
 function it_succeeds_when_it_has_no_local_repositories(GrumPHP $grumPHP, ProcessBuilder $processBuilder, Filesystem $filesystem, Process $process, ContextInterface $context)
 {
     $composerFile = 'composer.json';
     $grumPHP->getTaskConfiguration('composer')->willReturn(['file' => $composerFile, 'no_local_repository' => true]);
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('composer')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $context->getFiles()->willReturn(new FilesCollection([$composerFile = new SplFileInfo($composerFile, '.', $composerFile)]));
     $filesystem->readFromFileInfo($composerFile)->willReturn('{"repositories": [{"type": "vcs", "url": "/"}]}');
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(true);
 }