Пример #1
0
 public function testGetOption()
 {
     $this->initializeOptions();
     $definition = new InputDefinition(array($this->foo));
     $this->assertEquals($definition->getOption('foo'), $this->foo, '->getOption() returns a InputOption by its name');
     try {
         $definition->getOption('bar');
         $this->fail('->getOption() throws an exception if the option name does not exist');
     } catch (\Exception $e) {
     }
 }
Пример #2
0
  $t->pass('->addOption() throws a Exception if the another option is already registered with the same name');
}
try
{
  $definition->addOption($foo1);
  $t->fail('->addOption() throws a Exception if the another option is already registered with the same shortcut');
}
catch (\Exception $e)
{
  $t->pass('->addOption() throws a Exception if the another option is already registered with the same shortcut');
}

// ->getOption()
$t->diag('->getOption()');
$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');
Пример #3
0
 public function testGetOption()
 {
     $this->initializeOptions();
     $definition = new InputDefinition(array($this->foo));
     $this->assertEquals($this->foo, $definition->getOption('foo'), '->getOption() returns a InputOption by its name');
     try {
         $definition->getOption('bar');
         $this->fail('->getOption() throws an exception if the option name does not exist');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Exception', $e, '->getOption() throws an exception if the option name does not exist');
         $this->assertEquals('The "--bar" option does not exist.', $e->getMessage());
     }
 }