0 follower

Class Yiisoft\Yii\Debug\Api\Inspector\Command\CodeceptionCommand

InheritanceYiisoft\Yii\Debug\Api\Inspector\Command\CodeceptionCommand
ImplementsYiisoft\Yii\Debug\Api\Inspector\CommandInterface

Constants

Hide inherited constants

Constant Value Description Defined By
COMMAND_NAME 'test/codeception' Yiisoft\Yii\Debug\Api\Inspector\Command\CodeceptionCommand

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Yiisoft\Aliases\Aliases $aliases )
$aliases \Yiisoft\Aliases\Aliases

                public function __construct(private Aliases $aliases)
{
}

            
getDescription() public static method

public static string getDescription ( )

                public static function getDescription(): string
{
    return '';
}

            
getTitle() public static method

public static string getTitle ( )

                public static function getTitle(): string
{
    return 'Codeception';
}

            
run() public method

public Yiisoft\Yii\Debug\Api\Inspector\CommandResponse run ( )

                public function run(): CommandResponse
{
    $projectDirectory = $this->aliases->get('@root');
    $debugDirectory = $this->aliases->get('@runtime/debug');
    $extension = CodeceptionJSONReporter::class;
    $params = [
        'vendor/bin/codecept',
        'run',
        '--silent',
        '-e',
        $extension,
        '--override',
        "extensions: config: {$extension}: output-path: {$debugDirectory}",
        '-vvv',
    ];
    $process = new Process($params);
    $process
        ->setWorkingDirectory($projectDirectory)
        ->setTimeout(null)
        ->run();
    $processOutput = json_decode(
        file_get_contents($debugDirectory . DIRECTORY_SEPARATOR . CodeceptionJSONReporter::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
    );
}