You are here

public function InputTest::testOptions 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::testOptions()

File

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

Class

InputTest

Namespace

Symfony\Component\Console\Tests\Input

Code

public function testOptions() {
  $input = new ArrayInput(array(
    '--name' => 'foo',
  ), new InputDefinition(array(
    new InputOption('name'),
  )));
  $this
    ->assertEquals('foo', $input
    ->getOption('name'), '->getOption() returns the value for the given option');
  $input
    ->setOption('name', 'bar');
  $this
    ->assertEquals('bar', $input
    ->getOption('name'), '->setOption() sets the value for a given option');
  $this
    ->assertEquals(array(
    'name' => 'bar',
  ), $input
    ->getOptions(), '->getOptions() returns all option values');
  $input = new ArrayInput(array(
    '--name' => 'foo',
  ), new InputDefinition(array(
    new InputOption('name'),
    new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default'),
  )));
  $this
    ->assertEquals('default', $input
    ->getOption('bar'), '->getOption() returns the default value for optional options');
  $this
    ->assertEquals(array(
    'name' => 'foo',
    'bar' => 'default',
  ), $input
    ->getOptions(), '->getOptions() returns all option values, even optional ones');
}