Skip to content

Commit

Permalink
Fix progpilot task
Browse files Browse the repository at this point in the history
  • Loading branch information
Lander Vanderstraeten committed Jun 29, 2018
1 parent 3114418 commit dd0ba65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
5 changes: 4 additions & 1 deletion spec/Task/ProgpilotSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ function it_runs_the_suite(ProcessBuilder $processBuilder, Process $process, Con
function it_throws_exception_if_the_process_fails(
ProcessBuilder $processBuilder,
Process $process,
ContextInterface $context
ContextInterface $context,
ProcessFormatterInterface $formatter
) {
$formatter->format($process)->willReturn('format string');

$arguments = new ProcessArgumentsCollection();
$processBuilder->createArgumentsForCommand('progpilot')->willReturn($arguments);
$processBuilder->buildProcess($arguments)->willReturn($process);
Expand Down
30 changes: 7 additions & 23 deletions src/Task/Progpilot.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,39 @@
namespace GrumPHP\Task;

use GrumPHP\Runner\TaskResult;
use GrumPHP\Runner\TaskResultInterface;
use GrumPHP\Task\Context\ContextInterface;
use GrumPHP\Task\Context\GitPreCommitContext;
use GrumPHP\Task\Context\RunContext;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Progpilot task
*/
class Progpilot extends AbstractExternalTask
{
/**
* @return string
*/
public function getName()
public function getName(): string
{
return 'progpilot';
}

/**
* @return OptionsResolver
*/
public function getConfigurableOptions()
public function getConfigurableOptions(): OptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefaults(
[
$resolver->setDefaults([
'config_file' => '.progpilot/configuration.yml',
'triggered_by' => ['php']
]
);
]);

$resolver->addAllowedTypes('config_file', ['string', 'null']);
$resolver->addAllowedTypes('triggered_by', ['array']);

return $resolver;
}

/**
* {@inheritdoc}
*/
public function canRunInContext(ContextInterface $context)
public function canRunInContext(ContextInterface $context): bool
{
return ($context instanceof GitPreCommitContext || $context instanceof RunContext);
}

/**
* {@inheritdoc}
*/
public function run(ContextInterface $context)
public function run(ContextInterface $context): TaskResultInterface
{
$config = $this->getConfiguration();
$files = $context->getFiles()->extensions($config['triggered_by']);
Expand Down

0 comments on commit dd0ba65

Please sign in to comment.