} catch (\Exception $e) { $t->pass('->getOption() throws an exception if the option name does not exist'); } // ->hasOption() $t->diag('->hasOption()'); $definition = new InputDefinition(array($foo)); $t->is($definition->hasOption('foo'), true, '->hasOption() returns true if a InputOption exists for the given name'); $t->is($definition->hasOption('bar'), false, '->hasOption() returns false if a InputOption exists for the given name'); // ->hasShortcut() $t->diag('->hasShortcut()'); $definition = new InputDefinition(array($foo)); $t->is($definition->hasShortcut('f'), true, '->hasShortcut() returns true if a InputOption exists for the given shortcut'); $t->is($definition->hasShortcut('b'), false, '->hasShortcut() returns false if a InputOption exists for the given shortcut'); // ->getOptionForShortcut() $t->diag('->getOptionForShortcut()'); $definition = new InputDefinition(array($foo)); $t->is($definition->getOptionForShortcut('f'), $foo, '->getOptionForShortcut() returns a InputOption 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'); }
public function testHasShortcut() { $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); $this->assertEquals($definition->hasShortcut('f'), true, '->hasShortcut() returns true if a InputOption exists for the given shortcut'); $this->assertEquals($definition->hasShortcut('b'), false, '->hasShortcut() returns false if a InputOption exists for the given shortcut'); }