diff --git a/CHANGELOG.md b/CHANGELOG.md index 326b3ac..27b689c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip - Nothing ### Fixed -- Nothing +- Proxy Phpunit arguments #31 ### Removed - Nothing diff --git a/src/Commands/PhpUnit.php b/src/Commands/PhpUnit.php index 04a7f7b..c0acd94 100644 --- a/src/Commands/PhpUnit.php +++ b/src/Commands/PhpUnit.php @@ -3,8 +3,7 @@ namespace Feek\LaravelGitHooks\Commands; use Feek\LaravelGitHooks\CommandOutputFormatter; -use PHPUnit\TextUI\Command; -use PHPUnit\TextUI\TestRunner; +use Feek\LaravelGitHooks\ProgramExecutor; class PhpUnit extends BaseCommand { @@ -27,15 +26,21 @@ class PhpUnit extends BaseCommand */ protected $commandOutputFormatter; + /** + * @var ProgramExecutor + */ + protected $programExecutor; + /** * Create a new command instance. * * @param CommandOutputFormatter $commandOutputFormatter */ - public function __construct(CommandOutputFormatter $commandOutputFormatter) + public function __construct(ProgramExecutor $programExecutor, CommandOutputFormatter $commandOutputFormatter) { parent::__construct(); $this->commandOutputFormatter = $commandOutputFormatter; + $this->programExecutor = $programExecutor; } /** @@ -45,23 +50,20 @@ public function __construct(CommandOutputFormatter $commandOutputFormatter) */ public function handle() { - ob_start(); - - $result = (new Command())->run([ - '--disallow-test-output', - '--stop-on-failure' - ], false); + $arguments = $this->option('proxiedArguments'); - ob_end_clean(); + $this->programExecutor->exec("./vendor/bin/phpunit $arguments", $output, $statusCode); - $success = ($result === TestRunner::SUCCESS_EXIT); + if ($statusCode !== 0) { + foreach ($output as $line) { + $this->line($line); + } - if ($success) { - $this->info($this->commandOutputFormatter->success('Running PHPUnit')); - } else { $this->error($this->commandOutputFormatter->error('Running PHPUnit')); + } else { + $this->info($this->commandOutputFormatter->success('Running PHPUnit')); } - return $success ? 0 : 1; + return $statusCode; } }