Example #1
0
$serviceContainer->commandLoader->reset();
$serviceContainer->commandLoader->addCommands(array($foo));
$application->run('--config=nb_path1=cmdvalue1 --config=nb_path2=cmdvalue2 foo');
$t->is(nbConfig::get('nb_path1'), 'cmdvalue1', 'option "--config" creates multiple nbConfig properties');
$t->is(nbConfig::get('nb_path2'), 'cmdvalue2', 'option "--config" creates multiple nbConfig properties');
$t->ok($foo->hasExecuted(), 'command "foo" has executed');
$t->comment('nbApplicationTest - Test --enable-plugin option');
$serviceContainer->pluginLoader->addDir(nbConfig::get('nb_test_plugins_dir'));
$application = new DummyBeeApplication($serviceContainer);
$application->run('--enable-plugin=FirstPlugin first');
$t->ok(class_exists('DummyCommand'), 'option --enable-plugin enables a single plugin');
$t->comment('nbApplicationTest - Can execute with verbose option');
$application = new DummyBeeApplication($serviceContainer);
$foo = new DummyCommand('foo');
$serviceContainer->commandLoader->reset();
$serviceContainer->commandLoader->addCommands(array($foo));
$application->run('-v foo');
$t->is($foo->getLog(), 'Log message', 'command "foo" has logged correctly');
$application->run('foo');
$t->is($foo->getLog(), 'Log message', 'command "foo" has no log');
$t->comment('nbApplicationTest - Test load dummy configuration');
$dummy = new DummyCommandWithConfiguration();
$serviceContainer->commandLoader->reset();
$serviceContainer->commandLoader->addCommands(array($dummy));
$application->run('dummyconfig');
$t->is($dummy->getConfig('app_field0'), 'value1/value1', 'command has replaced tokens correctly');
$t->is($dummy->getConfig('app_field1'), 'value1', 'command has loaded configuration correctly');
$t->is($dummy->getConfig('app_field2'), 'value1', 'command has replaced tokens correctly');
$t->is($dummy->getConfig('app_field3'), 'value1/value1/value1', 'command has replaced tokens correctly');
$array = array(array('key1' => 'value1'), array('key2' => 'value2'));
$t->is($dummy->getConfig('app_array1'), $array, 'command has replaced array tokens correctly');