当前位置: 首页>>代码示例>>PHP>>正文


PHP Configuration\GrumPHP类代码示例

本文整理汇总了PHP中GrumPHP\Configuration\GrumPHP的典型用法代码示例。如果您正苦于以下问题:PHP GrumPHP类的具体用法?PHP GrumPHP怎么用?PHP GrumPHP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GrumPHP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ProcessArgumentsCollection

 function it_should_be_possible_to_configure_the_process_timeout(GrumPHP $config, ExternalCommand $externalCommandLocator)
 {
     $config->getProcessTimeout()->willReturn(120);
     $arguments = new ProcessArgumentsCollection(array('/usr/bin/grumphp'));
     $process = $this->buildProcess($arguments);
     $process->getTimeout()->shouldBe(120.0);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:7,代码来源:ProcessBuilderSpec.php

示例2: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $gitHooksPath = $this->paths()->getGitHooksDir();
     $resourceHooksPath = $this->paths()->getGitHookTemplatesDir() . $this->grumPHP->getHooksPreset();
     $resourceHooksPath = $this->paths()->getPathWithTrailingSlash($resourceHooksPath);
     $customHooksPath = $this->paths()->getPathWithTrailingSlash($this->grumPHP->getHooksDir());
     // Some git clients do not automatically create a git hooks folder.
     if (!$this->filesystem->exists($gitHooksPath)) {
         $this->filesystem->mkdir($gitHooksPath);
         $output->writeln(sprintf('<fg=yellow>Created git hooks folder at: %s</fg=yellow>', $gitHooksPath));
     }
     foreach (self::$hooks as $hook) {
         $gitHook = $gitHooksPath . $hook;
         $hookTemplate = new SplFileInfo($resourceHooksPath . $hook);
         if ($customHooksPath && $this->filesystem->exists($customHooksPath . $hook)) {
             $hookTemplate = new SplFileInfo($customHooksPath . $hook);
         }
         if (!$this->filesystem->exists($hookTemplate)) {
             throw new RuntimeException(sprintf('Could not find hook template for %s at %s.', $hook, $hookTemplate));
         }
         $content = $this->parseHookBody($hook, $hookTemplate);
         $this->filesystem->dumpFile($gitHook, $content);
         $this->filesystem->chmod($gitHook, 0775);
     }
     $output->writeln('<fg=yellow>Watch out! GrumPHP is sniffing your commits!<fg=yellow>');
 }
开发者ID:phpro,项目名称:grumphp,代码行数:33,代码来源:InitCommand.php

示例3: RunnerEvent

 function it_should_not_run_when_disabled(GrumPHP $grumPHP, Repository $repository)
 {
     $event = new RunnerEvent(new TasksCollection(), new GitPreCommitContext(new FilesCollection()), new TaskResultCollection());
     $grumPHP->ignoreUnstagedChanges()->willReturn(false);
     $this->saveStash($event);
     $this->popStash($event);
     $repository->run(Argument::cetera())->shouldNotBeCalled();
 }
开发者ID:phpro,项目名称:grumphp,代码行数:8,代码来源:StashUnstagedChangesSubscriberSpec.php

示例4:

 function it_runs_with_additional_modifiers(GrumPHP $grumPHP, GitCommitMsgContext $context)
 {
     $grumPHP->getTaskConfiguration('git_commit_message')->willReturn(['matchers' => ['/.*ümlaut/'], 'additional_modifiers' => 'u']);
     $context->getCommitMessage()->willReturn('message containing ümlaut');
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(true);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:8,代码来源:CommitMessageSpec.php

示例5: buildProcess

 /**
  * @param ProcessArgumentsCollection $arguments
  *
  * @return Process
  * @throws \GrumPHP\Exception\PlatformException
  */
 public function buildProcess(ProcessArgumentsCollection $arguments)
 {
     $builder = SymfonyProcessBuilder::create($arguments->getValues());
     $builder->setTimeout($this->config->getProcessTimeout());
     $process = $builder->getProcess();
     $this->logProcessInVerboseMode($process);
     $this->guardWindowsCmdMaxInputStringLimitation($process);
     return $process;
 }
开发者ID:phpro,项目名称:grumphp,代码行数:15,代码来源:ProcessBuilder.php

示例6: dirname

 function it_runs_the_suite_but_not_reaching_coverage(GrumPHP $grumPHP, GitCommitMsgContext $context)
 {
     $filename = dirname(dirname(dirname(__DIR__))) . '/test/fixtures/clover_coverage/60-percent-coverage.xml';
     $grumPHP->getTaskConfiguration('clover_coverage')->willReturn(['clover_file' => $filename, 'level' => 100]);
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->getResultCode()->shouldBe(TaskResult::FAILED);
     $result->getMessage()->shouldBe('Code coverage is 60%, which is below the accepted 100%' . PHP_EOL);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:9,代码来源:CloverCoverageSpec.php

示例7: sortByPriority

 /**
  * This method sorts the tasks by highest priority first.
  *
  * @param GrumPHP $grumPHP
  *
  * @return TasksCollection
  */
 public function sortByPriority(GrumPHP $grumPHP)
 {
     $priorityQueue = new SplPriorityQueue();
     $stableSortIndex = PHP_INT_MAX;
     foreach ($this->getIterator() as $task) {
         $metadata = $grumPHP->getTaskMetadata($task->getName());
         $priorityQueue->insert($task, array($metadata['priority'], $stableSortIndex--));
     }
     return new TasksCollection(array_values(iterator_to_array($priorityQueue)));
 }
开发者ID:eltonoliveira,项目名称:grumphp,代码行数:17,代码来源:TasksCollection.php

示例8: ProcessArgumentsCollection

 function it_runs_the_suite_when_composer_has_changed_and_run_always_is_false(GrumPHP $grumPHP, ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $grumPHP->getTaskConfiguration('securitychecker')->willReturn(array('run_always' => false));
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('security-checker')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('composer.lock', '.', 'composer.lock'))));
     $this->run($context);
 }
开发者ID:eltonoliveira,项目名称:grumphp,代码行数:11,代码来源:SecurityCheckerSpec.php

示例9: array

 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);
 }
开发者ID:alexlondon07,项目名称:grumphp,代码行数:12,代码来源:BlacklistSpec.php

示例10: ProcessArgumentsCollection

 function it_runs_if_there_are_no_files_but_always_execute_is_passed(GrumPHP $grumPHP, Process $process, ProcessBuilder $processBuilder, ContextInterface $context)
 {
     $grumPHP->getTaskConfiguration('phpunit')->willReturn(['always_execute' => true]);
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('phpunit')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $context->getFiles()->willReturn(new FilesCollection());
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(true);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:13,代码来源:PhpunitSpec.php

示例11: ProcessArgumentsCollection

 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);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:13,代码来源:BlacklistSpec.php

示例12: FilesCollection

 function it_runs_the_suite_for_all_files(GrumPHP $grumPHP, ProcessBuilder $processBuilder, Process $process, RunContext $context, PhpCsFixerFormatter $formatter)
 {
     $grumPHP->getTaskConfiguration('phpcsfixer')->willReturn(array('config_file' => '.php_cs'));
     $formatter->resetCounter()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array($file1 = new SplFileInfo('file1.php', '.', 'file1.php'), $file2 = new SplFileInfo('file2.php', '.', 'file2.php'))));
     $processBuilder->createArgumentsForCommand('php-cs-fixer')->willReturn(new ProcessArgumentsCollection());
     $processBuilder->buildProcess(Argument::that(function (ProcessArgumentsCollection $args) use($file1, $file2) {
         return !($args->contains($file1) || $args->contains($file2));
     }))->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf('GrumPHP\\Runner\\TaskResultInterface');
     $result->isPassed()->shouldBe(true);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:15,代码来源:PhpCsFixerSpec.php

示例13:

 function it_should_sort_on_priority(TaskInterface $task1, TaskInterface $task2, TaskInterface $task3, GrumPHP $grumPHP)
 {
     $this->beConstructedWith(array($task1, $task2, $task3));
     $task1->getName()->willReturn('task1');
     $task2->getName()->willReturn('task2');
     $task3->getName()->willReturn('task3');
     $grumPHP->getTaskMetadata('task1')->willReturn(array('priority' => 100));
     $grumPHP->getTaskMetadata('task2')->willReturn(array('priority' => 200));
     $grumPHP->getTaskMetadata('task3')->willReturn(array('priority' => 100));
     $result = $this->sortByPriority($grumPHP);
     $result->shouldBeAnInstanceOf('GrumPHP\\Collection\\TasksCollection');
     $result->count()->shouldBe(3);
     $tasks = $result->toArray();
     $tasks[0]->shouldBe($task2);
     $tasks[1]->shouldBe($task1);
     $tasks[2]->shouldBe($task3);
 }
开发者ID:eltonoliveira,项目名称:grumphp,代码行数:17,代码来源:TasksCollectionSpec.php

示例14: let

 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
 {
     $grumPHP->getTaskConfiguration('composer_script')->willReturn(['script' => 'test']);
     $this->beConstructedWith($grumPHP, $processBuilder, $formatter);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:5,代码来源:ComposerScriptSpec.php

示例15: run

 /**
  * @param ContextInterface $context
  *
  * @throws FailureException if any of the tasks fail
  */
 public function run(ContextInterface $context)
 {
     $failures = false;
     $messages = array();
     $tasks = $this->tasks->filterByContext($context)->sortByPriority($this->grumPHP);
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, new RunnerEvent($tasks));
     foreach ($tasks as $task) {
         try {
             $this->eventDispatcher->dispatch(TaskEvents::TASK_RUN, new TaskEvent($task));
             $task->run($context);
             $this->eventDispatcher->dispatch(TaskEvents::TASK_COMPLETE, new TaskEvent($task));
         } catch (RuntimeException $e) {
             $this->eventDispatcher->dispatch(TaskEvents::TASK_FAILED, new TaskFailedEvent($task, $e));
             $messages[] = $e->getMessage();
             $failures = true;
             if ($this->grumPHP->stopOnFailure()) {
                 break;
             }
         }
     }
     if ($failures) {
         $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_FAILED, new RunnerFailedEvent($tasks, $messages));
         throw new FailureException(implode(PHP_EOL, $messages));
     }
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_COMPLETE, new RunnerEvent($tasks));
 }
开发者ID:eltonoliveira,项目名称:grumphp,代码行数:31,代码来源:TaskRunner.php


注:本文中的GrumPHP\Configuration\GrumPHP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。