Exemplo n.º 1
0
//$t->is($command1->getSynopsys(), 'bee foo', '->getSynopsys() is "bee foo"');
//$t->is($command2->getSynopsys(), 'bee ns:bar [foo]', '->getSynopsys() is "bee ns:bar [foo]"');
$t->comment('nbCommandTest - Test shortcut');
$t->is($command1->hasShortcut('f'), true, '->hasShortcut() is true with "f"');
$t->is($command1->hasShortcut(':f'), true, '->hasShortcut() is true with ":f"');
$t->is($command1->hasShortcut('b'), false, '->hasShortcut() is true with "b"');
$t->is($command1->hasShortcut(':b'), false, '->hasShortcut() is true with ":b"');
$t->is($command2->hasShortcut('n:b'), true, '->hasShortcut() is true with "n:b"');
$t->is($command2->hasShortcut('ns:b'), true, '->hasShortcut() is true with "ns:b"');
$t->is($command2->hasShortcut('b'), true, '->hasShortcut() is true with "b"');
$t->is($command2->hasShortcut(':b'), true, '->hasShortcut() is true with ":b"');
$t->is($command2->hasShortcut('ns:d'), false, '->hasShortcut() is true with "ns:d"');
$t->comment('nbCommandTest - Test brief description');
$command = new DummyCommand('foo');
$t->is($command->getBriefDescription(), '', '->getBriefDescrition() is ""');
$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'));
Exemplo n.º 2
0
<?php

require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new lime_test();
$fooArgument = new nbArgument('foo');
$barOption = new nbOption('bar');
$command1 = new DummyCommand("ns2:bas", new nbArgumentSet(array($fooArgument)), new nbOptionSet(array($barOption)));
$command1->setBriefDescription('brief description');
$aliasCommand = new nbAliasCommand('ns:alias', $command1);
$t->comment('nbAliasCommandTest - Test fullname');
$t->is($aliasCommand->getFullname(), "ns:alias", '->getFullName() returns a name without ":"');
$t->comment('nbAliasCommandTest - Test arguments');
$t->is($aliasCommand->getArguments()->count(), 1, '->getArguments() returns 1 argument');
$t->is($aliasCommand->getOptions()->count(), 2, '->getOptions() returns 1 options');
$t->comment('nbAliasCommandTest - Test description');
$t->is($aliasCommand->getBriefDescription(), "brief description", '->getBriefDescription() returns a the contained command description');
$t->comment('nbAliasCommandTest - Test run (success)');
$t->ok($aliasCommand->run(new nbCommandLineParser(), ''));
$t->ok($command1->hasExecuted());
$t->comment('nbAliasCommandTest - Test run (failure)');
$command1->failOnExecute();
$t->ok(!$aliasCommand->run(new nbCommandLineParser(), ''));
$t->ok($command1->hasExecuted());