Example #1
0
    $t->pass('->addOption() throws a Exception if the another option is already registered with the same shortcut');
}
// ->getOption()
$t->diag('->getOption()');
$definition = new Definition(array($foo));
$t->is($definition->getOption('foo'), $foo, '->getOption() returns a Option by its name');
try {
    $definition->getOption('bar');
    $t->fail('->getOption() throws an exception if the option name does not exist');
} catch (\Exception $e) {
    $t->pass('->getOption() throws an exception if the option name does not exist');
}
// ->hasOption()
$t->diag('->hasOption()');
$definition = new Definition(array($foo));
$t->is($definition->hasOption('foo'), true, '->hasOption() returns true if a Option exists for the given name');
$t->is($definition->hasOption('bar'), false, '->hasOption() returns false if a Option exists for the given name');
// ->hasShortcut()
$t->diag('->hasShortcut()');
$definition = new Definition(array($foo));
$t->is($definition->hasShortcut('f'), true, '->hasShortcut() returns true if a Option exists for the given shortcut');
$t->is($definition->hasShortcut('b'), false, '->hasShortcut() returns false if a Option exists for the given shortcut');
// ->getOptionForShortcut()
$t->diag('->getOptionForShortcut()');
$definition = new Definition(array($foo));
$t->is($definition->getOptionForShortcut('f'), $foo, '->getOptionForShortcut() returns a Option by its shortcut');
try {
    $definition->getOptionForShortcut('l');
    $t->fail('->getOption() throws an exception if the shortcut does not exist');
} catch (\Exception $e) {
    $t->pass('->getOption() throws an exception if the shortcut does not exist');