$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'); $t->is($command2->getOptions()->count(), 0, '->getOptions() returns 0 options'); $t->is($command3->getOptions()->count(), 1, '->getOptions() returns 1 option'); $command = new DummyCommand(); $command->addOption(new nbOption('foo')); $t->is($command->getOptions()->count(), 1, '->addOption() added 1 option'); //$t->comment('nbCommandTest - Test synopsys'); //$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');
$application->run('foo'); $t->ok($foo->hasExecuted(), '->run() executes command "foo"'); $application->run('bar test'); $t->ok($bar->hasExecuted(), '->run() executes command "bar test"'); $t->is($bar->getArgument('first'), 'test', '->run() executes command "bar test"'); $application->run('bas -f'); $t->ok($bas->hasExecuted(), '->run() executes command "bas -f"'); $t->is($bas->getOption('first'), true, '->run() executes command "bas -f"'); $application->run('fou'); $t->ok($fas->hasExecuted(), '->run() executes command "fas" with alias "fou"'); $t->comment('ApplicationTest - Test VerifyOption'); $application = new DummyApplication($serviceContainer, array(), array(new nbOption('option1'))); $foo = new DummyCommand('foo'); $foo->addOption(new nbOption('option1')); $bar = new DummyCommand('bar'); $bar->addOption(new nbOption('option2')); $list = new DummyCommand('list'); $serviceContainer->commandLoader->reset(); $serviceContainer->commandLoader->addCommands(array($foo, $bar, $list)); try { $application->run('foo'); $t->fail('nbApplication::verifyOption() throws if there are some options in beeApplication and in new command'); } catch (Exception $e) { $t->pass('nbApplication::verifyOption() throws if there are some options in beeApplication and in new command'); } try { $application->run('bar'); $t->pass('nbApplication::verifyOption() doesn\'t throw if there are different options in beeApplication and in new command'); } catch (Exception $e) { $t->fail('nbApplication::verifyOption() doesn\'t throw if there are different options in beeApplication and in new command'); }