$command->setBriefDescription('command brief description'); $t->is($command->getBriefDescription(), 'command brief description', '->getBriefDescrition() is "command brief description"'); $t->comment('nbCommandTest - Test detailed description'); $command = new DummyCommand('foo'); $t->is($command->getDescription(), '', '->getDescription() is ""'); $command->setDescription('command description'); $t->is($command->getDescription(), 'command description', '->getDescription() is "command description"'); $t->comment('nbCommandTest - Test aliases'); $command = new DummyCommand("foo"); $t->ok(!$command->hasAliases(), '->hasAliases() returns false'); $t->ok(!$command->hasAlias('f'), '->hasAlias() returns false'); $command->setAlias('f'); $t->ok($command->hasAliases(), '->hasAliases() returns true'); $t->ok($command->hasAlias('f'), '->hasAlias() returns true'); $command = new DummyCommand("foo"); $command->setAliases(array('f', 'fo')); $t->ok($command->hasAliases(), '->setAliases() sets 2 alias'); $t->ok($command->hasAlias('f'), '->hasAlias() returns true'); $t->ok($command->hasAlias('fo'), '->hasAlias() returns true'); try { $command->setAlias('f'); $t->fail('->setAlias() throws an InvalidArgumentException if command alias already defined'); } catch (InvalidArgumentException $e) { $t->pass('->setAlias() throws an InvalidArgumentException if command alias already defined'); } $t->comment('nbCommandTest - Test command without arguments'); try { $command = new DummyNoArgsCommand(); $t->pass('->new doesn\'t throws exception'); } catch (Exception $e) { $t->fail('->new doesn\'t throws exception');
$t->pass('->getByShortcut() throw a RangeException for shortcut "u"'); } try { $set->getCommand('b'); $t->fail('->getByShortcut() throw a RangeException for shortcut "b" because ambiguous'); } catch (LogicException $e) { $t->pass('->getByShortcut() throw a RangeException for shortcut "b" because ambiguous'); } try { $set->getCommand('ns:ba'); $t->fail('->getByShortcut() throw a RangeException for shortcut "ns:ba" because ambiguous'); } catch (LogicException $e) { $t->pass('->getByShortcut() throw a RangeException for shortcut "ns:ba" because ambiguous'); } $t->comment('nbCommandSetTest - Test aliases'); $command = new DummyCommand("foo"); $command->setAliases(array('b', 'bar')); $set = new nbCommandSet(array($command)); $t->ok($set->hasCommand('b'), '->hasCommand() returns true for alias "b"'); $t->ok($set->hasCommand('bar'), '->hasCommand() returns true for alias "bar"'); $t->isa_ok($set->getCommand('b'), 'DummyCommand', '->getCommand() returns a command for alias "b"'); $t->isa_ok($set->getCommand('bar'), 'DummyCommand', '->getCommand() returns a command for alias "bar"'); $t->comment('nbCommandSetTest - Test command with same name an different namespace'); $command1 = new DummyCommand("foo:cmd"); $command2 = new DummyCommand("bar:cmd"); try { new nbCommandSet(array($command1, $command2)); $t->pass('->new doesn\'t throws exception'); } catch (Exception $e) { $t->fail('->new doesn\'t throws exception'); }