public function testGetOptionForShortcut() { $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); $this->assertEquals($definition->getOptionForShortcut('f'), $this->foo, '->getOptionForShortcut() returns a InputOption by its shortcut'); try { $definition->getOptionForShortcut('l'); $this->fail('->getOption() throws an exception if the shortcut does not exist'); } catch (\Exception $e) { } }
// ->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'); } // ->getOptionDefaults() $t->diag('->getOptionDefaults()'); $definition = new InputDefinition(array( new InputOption('foo1', null, InputOption::PARAMETER_NONE), new InputOption('foo2', null, InputOption::PARAMETER_REQUIRED),
public function testGetOptionForShortcut() { $this->initializeOptions(); $definition = new InputDefinition(array($this->foo)); $this->assertEquals($this->foo, $definition->getOptionForShortcut('f'), '->getOptionForShortcut() returns a InputOption by its shortcut'); try { $definition->getOptionForShortcut('l'); $this->fail('->getOption() throws an exception if the shortcut does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('\\Exception', $e, '->getOption() throws an exception if the shortcut does not exist'); $this->assertEquals('The "-l" option does not exist.', $e->getMessage()); } }