mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 02:37:22 +01:00
Refactors addOutput
This commit is contained in:
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Actions;
|
namespace Pest\Actions;
|
||||||
|
|
||||||
|
use Pest\Contracts\Plugins\AddsOutput;
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
use Pest\Plugin\Loader;
|
use Pest\Plugin\Loader;
|
||||||
|
|
||||||
@ -30,4 +31,20 @@ final class InteractsWithPlugins
|
|||||||
|
|
||||||
return $argv;
|
return $argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an opportunity for any plugins that want
|
||||||
|
* to provide additional output after test execution.
|
||||||
|
*/
|
||||||
|
public static function addOutput(int $result): int
|
||||||
|
{
|
||||||
|
$plugins = Loader::getPlugins(AddsOutput::class);
|
||||||
|
|
||||||
|
/** @var AddsOutput $plugin */
|
||||||
|
foreach ($plugins as $plugin) {
|
||||||
|
$result = $plugin->addOutput($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace Pest\Console;
|
|||||||
|
|
||||||
use Pest\Actions\AddsDefaults;
|
use Pest\Actions\AddsDefaults;
|
||||||
use Pest\Actions\AddsTests;
|
use Pest\Actions\AddsTests;
|
||||||
|
use Pest\Actions\InteractsWithPlugins;
|
||||||
use Pest\Actions\LoadStructure;
|
use Pest\Actions\LoadStructure;
|
||||||
use Pest\Actions\ValidatesConfiguration;
|
use Pest\Actions\ValidatesConfiguration;
|
||||||
use Pest\Contracts\Plugins\AddsOutput;
|
use Pest\Contracts\Plugins\AddsOutput;
|
||||||
@ -114,16 +115,7 @@ final class Command extends BaseCommand
|
|||||||
LoadStructure::in($this->testSuite->rootPath);
|
LoadStructure::in($this->testSuite->rootPath);
|
||||||
|
|
||||||
$result = parent::run($argv, false);
|
$result = parent::run($argv, false);
|
||||||
|
$result = InteractsWithPlugins::addOutput($result);
|
||||||
/*
|
|
||||||
* Let's call all plugins that want to add output after test execution
|
|
||||||
*/
|
|
||||||
$plugins = Loader::getPlugins(AddsOutput::class);
|
|
||||||
|
|
||||||
/** @var AddsOutput $plugin */
|
|
||||||
foreach ($plugins as $plugin) {
|
|
||||||
$result = $plugin->addOutput($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit($result);
|
exit($result);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user