$definition = new InputDefinition(array($foo)); $t->is($definition->getOption('foo'), $foo, '->getOption() returns a InputOption 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 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');
public function testHasOption() { $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); $this->assertEquals($definition->hasOption('foo'), true, '->hasOption() returns true if a InputOption exists for the given name'); $this->assertEquals($definition->hasOption('bar'), false, '->hasOption() returns false if a InputOption exists for the given name'); }