getTaskConfiguration() public method

public getTaskConfiguration ( string $taskName ) : array
$taskName string
return array
Example #1
0
 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);
 }
Example #2
0
 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);
 }
 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);
 }
Example #4
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);
 }
Example #5
0
 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);
 }
Example #6
0
 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);
 }
Example #7
0
 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);
 }
Example #8
0
 function let(GrumPHP $grumPHP, YamlLinter $linter)
 {
     $grumPHP->getTaskConfiguration('yamllint')->willReturn([]);
     $this->beConstructedWith($grumPHP, $linter);
 }
Example #9
0
 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
 {
     $grumPHP->getTaskConfiguration('shell')->willReturn(['scripts' => ['script.sh']]);
     $this->beConstructedWith($grumPHP, $processBuilder, $formatter);
 }
Example #10
0
 function it_runs_with_additional_modifiers(GrumPHP $grumPHP, GitCommitMsgContext $context)
 {
     $grumPHP->getTaskConfiguration('git_commit_message')->willReturn(array('matchers' => array('/.*ümlaut/'), 'additional_modifiers' => 'u'));
     $context->getCommitMessage()->willReturn('message containing ümlaut');
     $this->run($context);
 }
Example #11
0
 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
 {
     $grumPHP->getTaskConfiguration('phing')->willReturn([]);
     $this->beConstructedWith($grumPHP, $processBuilder, $formatter);
 }
Example #12
0
 function let(GrumPHP $grumPHP, JsonLinter $linter)
 {
     $grumPHP->getTaskConfiguration('jsonlint')->willReturn(array());
     $this->beConstructedWith($grumPHP, $linter);
 }
Example #13
0
 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);
 }
Example #14
0
 function let(GrumPHP $grumPHP, ParserInterface $parser)
 {
     $parser->isInstalled()->willReturn(true);
     $grumPHP->getTaskConfiguration('phpparser')->willReturn([]);
     $this->beConstructedWith($grumPHP, $parser);
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     return array_merge($this->getDefaultConfiguration(), $this->grumPHP->getTaskConfiguration($this->getName()));
 }
Example #16
0
 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
 {
     $grumPHP->getTaskConfiguration('composer_script')->willReturn(['script' => 'test']);
     $this->beConstructedWith($grumPHP, $processBuilder, $formatter);
 }
Example #17
0
 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
 {
     $grumPHP->getTaskConfiguration('npm_script')->willReturn(['script' => 'test', 'working_directory' => './']);
     $this->beConstructedWith($grumPHP, $processBuilder, $formatter);
 }
Example #18
0
 function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder)
 {
     $grumPHP->getTaskConfiguration('behat')->willReturn(array());
     $this->beConstructedWith($grumPHP, $processBuilder);
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     $configured = $this->grumPHP->getTaskConfiguration($this->getName());
     return $this->getConfigurableOptions()->resolve($configured);
 }