Пример #1
0
 public function testGetArgument()
 {
     $this->initializeArguments();
     $definition = new InputDefinition();
     $definition->addArguments(array($this->foo));
     $this->assertEquals($definition->getArgument('foo'), $this->foo, '->getArgument() returns a InputArgument by its name');
     try {
         $definition->getArgument('bar');
         $this->fail('->getArgument() throws an exception if the InputArgument name does not exist');
     } catch (\Exception $e) {
     }
 }
Пример #2
0
$definition->addArgument($foo);
try
{
  $definition->addArgument($foo2);
  $t->fail('->addArgument() throws an exception if you try to add a required argument after an optional one');
}
catch (\Exception $e)
{
  $t->pass('->addArgument() throws an exception if you try to add a required argument after an optional one');
}

// ->getArgument()
$t->diag('->getArgument()');
$definition = new InputDefinition();
$definition->addArguments(array($foo));
$t->is($definition->getArgument('foo'), $foo, '->getArgument() returns a InputArgument by its name');
try
{
  $definition->getArgument('bar');
  $t->fail('->getArgument() throws an exception if the InputArgument name does not exist');
}
catch (\Exception $e)
{
  $t->pass('->getArgument() throws an exception if the InputArgument name does not exist');
}

// ->hasArgument()
$t->diag('->hasArgument()');
$definition = new InputDefinition();
$definition->addArguments(array($foo));
$t->is($definition->hasArgument('foo'), true, '->hasArgument() returns true if a InputArgument exists for the given name');
Пример #3
0
 public function testGetArgument()
 {
     $this->initializeArguments();
     $definition = new InputDefinition();
     $definition->addArguments(array($this->foo));
     $this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name');
     try {
         $definition->getArgument('bar');
         $this->fail('->getArgument() throws an exception if the InputArgument name does not exist');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Exception', $e, '->getArgument() throws an exception if the InputArgument name does not exist');
         $this->assertEquals('The "bar" argument does not exist.', $e->getMessage());
     }
 }