Kraken\_Unit\Console\Client\_T\TCommand::assertCommand PHP Method

assertCommand() public method

public assertCommand ( Command $command, string $name, string $desc = "#(.*?)#si", mixed[] $args = [], mixed[] $opts = [] )
$command Kraken\Console\Client\Command\Command
$name string
$desc string
$args mixed[]
$opts mixed[]
    public function assertCommand(Command $command, $name, $desc = "#(.*?)#si", $args = [], $opts = [])
    {
        $this->assertSame($name, $command->getName());
        $this->assertRegExp($desc, $command->getDescription());
        $def = $command->getDefinition();
        foreach ($args as $arg) {
            $this->assertTrue($def->hasArgument($arg[0]));
            if ($arg[1] === InputArgument::REQUIRED) {
                $this->assertTrue($def->getArgument($arg[0])->isRequired());
            }
            if ($arg[1] === InputArgument::OPTIONAL) {
                $this->assertFalse($def->getArgument($arg[0])->isRequired());
            }
            if ($arg[1] === InputArgument::IS_ARRAY) {
                $this->assertTrue($def->getArgument($arg[0])->isArray());
            }
            if (isset($arg[2])) {
                $this->assertRegExp($arg[2], $def->getArgument($arg[0])->getDescription());
            }
        }
        foreach ($opts as $opt) {
            $this->assertTrue($def->hasOption($opt[0]));
            if (isset($opt[1])) {
                $this->assertSame($opt[1], $def->getOption($opt[0])->getShortcut());
            }
            if ($opt[2] === InputOption::VALUE_REQUIRED) {
                $this->assertTrue($def->getOption($opt[0])->isValueRequired());
            }
            if ($opt[2] === InputOption::VALUE_OPTIONAL) {
                $this->assertTrue($def->getOption($opt[0])->isValueOptional());
            }
            if ($opt[2] === InputOption::VALUE_IS_ARRAY) {
                $this->assertTrue($def->getOption($opt[0])->isArray());
            }
            if (isset($opt[3])) {
                $this->assertRegExp($opt[3], $def->getOption($opt[0])->getDescription());
            }
            if (isset($opt[4])) {
                $this->assertSame($opt[4], $def->getOption($opt[0])->getDefault());
            }
        }
    }