Example #1
0
 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');
 }
Example #2
0
 /**
  * @dataProvider provideOptions
  */
 public function testParseOptions($input, $options, $expectedOptions, $message)
 {
     $input = new ArrayInput($input, new InputDefinition($options));
     $this->assertEquals($expectedOptions, $input->getOptions(), $message);
 }