Class Yiisoft\Yii\Debug\Api\Inspector\Command\PHPUnitCommand
| Inheritance | Yiisoft\Yii\Debug\Api\Inspector\Command\PHPUnitCommand |
|---|---|
| Implements | Yiisoft\Yii\Debug\Api\Inspector\CommandInterface |
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| COMMAND_NAME | 'test/phpunit' | Yiisoft\Yii\Debug\Api\Inspector\Command\PHPUnitCommand |
Method Details
| public mixed __construct ( \Yiisoft\Aliases\Aliases $aliases ) | ||
| $aliases | \Yiisoft\Aliases\Aliases | |
public function __construct(private Aliases $aliases)
{
}
| public static string getDescription ( ) |
public static function getDescription(): string
{
return '';
}
| public Yiisoft\Yii\Debug\Api\Inspector\CommandResponse run ( ) |
public function run(): CommandResponse
{
$projectDirectory = $this->aliases->get('@root');
$debugDirectory = $this->aliases->get('@runtime/debug');
$extension = PHPUnitJSONReporter::class;
$params = [
'vendor/bin/phpunit',
'--printer',
$extension,
'-vvv',
];
$process = new Process($params);
$process
->setEnv([PHPUnitJSONReporter::ENVIRONMENT_VARIABLE_DIRECTORY_NAME => $debugDirectory])
->setWorkingDirectory($projectDirectory)
->setTimeout(null)
->run();
$processOutput = json_decode(
file_get_contents($debugDirectory . DIRECTORY_SEPARATOR . PHPUnitJSONReporter::FILENAME),
true,
512,
JSON_THROW_ON_ERROR
);
if (!$process->getExitCode() > 1) {
return new CommandResponse(
status: CommandResponse::STATUS_FAIL,
result: null,
errors: array_filter([$processOutput, $process->getErrorOutput()]),
);
}
return new CommandResponse(
status: $process->isSuccessful() ? CommandResponse::STATUS_OK : CommandResponse::STATUS_ERROR,
result: $processOutput
);
}
Signup or Login in order to comment.