You are here

public function InputTest::testArguments in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Tests/Input/InputTest.php \Symfony\Component\Console\Tests\Input\InputTest::testArguments()

File

vendor/symfony/console/Tests/Input/InputTest.php, line 61

Class

InputTest

Namespace

Symfony\Component\Console\Tests\Input

Code

public function testArguments() {
  $input = new ArrayInput(array(
    'name' => 'foo',
  ), new InputDefinition(array(
    new InputArgument('name'),
  )));
  $this
    ->assertEquals('foo', $input
    ->getArgument('name'), '->getArgument() returns the value for the given argument');
  $input
    ->setArgument('name', 'bar');
  $this
    ->assertEquals('bar', $input
    ->getArgument('name'), '->setArgument() sets the value for a given argument');
  $this
    ->assertEquals(array(
    'name' => 'bar',
  ), $input
    ->getArguments(), '->getArguments() returns all argument values');
  $input = new ArrayInput(array(
    'name' => 'foo',
  ), new InputDefinition(array(
    new InputArgument('name'),
    new InputArgument('bar', InputArgument::OPTIONAL, '', 'default'),
  )));
  $this
    ->assertEquals('default', $input
    ->getArgument('bar'), '->getArgument() returns the default value for optional arguments');
  $this
    ->assertEquals(array(
    'name' => 'foo',
    'bar' => 'default',
  ), $input
    ->getArguments(), '->getArguments() returns all argument values, even optional ones');
}