$input = new ArrayInput(array('--foo'));
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
+
+ $input = new ArrayInput(array('--foo', '--', '--bar'));
+ $this->assertTrue($input->hasParameterOption('--bar'), '->hasParameterOption() returns true if an option is present in the passed parameters');
+ $this->assertFalse($input->hasParameterOption('--bar', true), '->hasParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
}
public function testGetParameterOption()
{
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
+ $this->assertFalse($input->getParameterOption('--bar'), '->getParameterOption() returns the default if an option is not present in the passed parameters');
$input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
+
+ $input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
+ $this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
+ $this->assertFalse($input->getParameterOption('--bar', false, true), '->getParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
}
public function testParseArguments()
array('foo' => 'bar'),
'->parse() parses short options',
),
+ array(
+ array('--' => null, '-f' => 'bar'),
+ array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
+ array('foo' => 'default'),
+ '->parse() does not parse opts after an end of options signal',
+ ),
+ array(
+ array('--' => null),
+ array(),
+ array(),
+ '->parse() does not choke on end of options signal',
+ ),
);
}