Skip to content

Commit

Permalink
Add php unit bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
Lander Vanderstraeten committed Nov 30, 2018
1 parent 442cce4 commit 6be5019
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
9 changes: 8 additions & 1 deletion spec/Task/PhpunitBridgeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,15 @@ function it_runs_the_suite(ProcessBuilder $processBuilder, Process $process, Con
$result->isPassed()->shouldBe(true);
}

function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
function it_throws_exception_if_the_process_fails(
ProcessBuilder $processBuilder,
Process $process,
ContextInterface $context,
ProcessFormatterInterface $formatter
)
{
$formatter->format($process)->willReturn('format string');

$arguments = new ProcessArgumentsCollection();
$processBuilder->createArgumentsForCommand('simple-phpunit')->willReturn($arguments);
$processBuilder->buildProcess($arguments)->willReturn($process);
Expand Down
26 changes: 5 additions & 21 deletions src/Task/PhpunitBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,20 @@
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;

/**
* PhpunitBridge task
*
* @link https://symfony.com/doc/current/components/phpunit_bridge.html
*/
class PhpunitBridge extends AbstractExternalTask
{
/**
* @return string
*/
public function getName()
public function getName(): string
{
return 'phpunitbridge';
}

/**
* @return OptionsResolver
*/
public function getConfigurableOptions()
public function getConfigurableOptions(): OptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefaults([
Expand All @@ -44,18 +34,12 @@ public function getConfigurableOptions()
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();

Expand Down

0 comments on commit 6be5019

Please sign in to comment.