Пример #1
0
    $t->fail('command name can\'t be empty');
} catch (InvalidArgumentException $e) {
    $t->pass('command name can\'t be empty');
}
try {
    new DummyCommand('ns:');
    $t->fail('command name can\'t be empty');
} catch (InvalidArgumentException $e) {
    $t->pass('command name can\'t be empty');
}
$command = new DummyCommand('foo');
$t->is($command->getArguments()->count(), 0, '->__construct() returns a command with no arguments');
$t->is($command->getOptions()->count(), 0, '->__construct() returns a command with no options');
$t->comment('nbCommandTest - Test name');
$t->is($command1->getName(), "foo", '->getName() returns a command with name "foo"');
$t->is($command2->getName(), "bar", '->getName() returns a command with name "bar"');
$t->comment('nbCommandTest - Test namespace');
$t->is($command1->getNamespace(), "", '->getNamespace() returns an empty namespace');
$t->is($command2->getNamespace(), "ns", '->getNamespace() returns a namespace "ns"');
$t->comment('nbCommandTest - Test fullname');
$t->is($command1->getFullname(), "foo", '->getFullName() returns a name without ":"');
$t->is($command2->getFullname(), "ns:bar", '->__construct() returns "ns:bar"');
$t->comment('nbCommandTest - Test arguments');
$t->is($command1->getArguments()->count(), 0, '->getArguments() returns 0 arguments');
$t->is($command2->getArguments()->count(), 1, '->getArguments() returns 1 argument');
$t->is($command3->getArguments()->count(), 0, '->getArguments() returns 0 arguments');
$command = new DummyCommand();
$command->addArgument(new nbArgument('foo'));
$t->is($command->getArguments()->count(), 1, '->addArgument() added 1 argument');
$t->comment('nbCommandTest - Test options');
$t->is($command1->getOptions()->count(), 0, '->getOptions() returns 0 options');