12 namespace Symfony\Component\Console\Tests\Input;
24 $this->assertNull($input->getFirstArgument(),
'->getFirstArgument() returns null if no argument were passed');
25 $input =
new ArrayInput(array(
'name' =>
'Fabien'));
26 $this->assertEquals(
'Fabien', $input->getFirstArgument(),
'->getFirstArgument() returns the first passed argument');
27 $input =
new ArrayInput(array(
'--foo' =>
'bar',
'name' =>
'Fabien'));
28 $this->assertEquals(
'Fabien', $input->getFirstArgument(),
'->getFirstArgument() returns the first passed argument');
33 $input =
new ArrayInput(array(
'name' =>
'Fabien',
'--foo' =>
'bar'));
34 $this->assertTrue($input->hasParameterOption(
'--foo'),
'->hasParameterOption() returns true if an option is present in the passed parameters');
35 $this->assertFalse($input->hasParameterOption(
'--bar'),
'->hasParameterOption() returns false if an option is not present in the passed parameters');
38 $this->assertTrue($input->hasParameterOption(
'--foo'),
'->hasParameterOption() returns true if an option is present in the passed parameters');
43 $input =
new ArrayInput(array(
'name' =>
'Fabien',
'--foo' =>
'bar'));
44 $this->assertEquals(
'bar', $input->getParameterOption(
'--foo'),
'->getParameterOption() returns the option of specified name');
46 $input =
new ArrayInput(array(
'Fabien',
'--foo' =>
'bar'));
47 $this->assertEquals(
'bar', $input->getParameterOption(
'--foo'),
'->getParameterOption() returns the option of specified name');
54 $this->assertEquals(array(
'name' =>
'foo'), $input->getArguments(),
'->parse() parses required arguments');
64 $this->assertEquals($expectedOptions, $input->getOptions(), $message);
71 array(
'--foo' =>
'bar'),
73 array(
'foo' =>
'bar'),
74 '->parse() parses long options',
77 array(
'--foo' =>
'bar'),
79 array(
'foo' =>
'bar'),
80 '->parse() parses long options with a default value',
83 array(
'--foo' => null),
85 array(
'foo' =>
'default'),
86 '->parse() parses long options with a default value',
91 array(
'foo' =>
'bar'),
92 '->parse() parses short options',
102 $this->setExpectedException(
'InvalidArgumentException', $expectedExceptionMessage);
111 array(
'foo' =>
'foo'),
113 'The "foo" argument does not exist.',
116 array(
'--foo' => null),
118 'The "--foo" option requires a value.',
121 array(
'--foo' =>
'foo'),
123 'The "--foo" option does not exist.',
126 array(
'-o' =>
'foo'),
128 'The "-o" option does not exist.',
135 $input =
new ArrayInput(array(
'-f' => null,
'-b' =>
'bar',
'--foo' =>
'b a z',
'--lala' => null,
'test' =>
'Foo',
'test2' =>
"A\nB'C"));
136 $this->assertEquals(
'-f -b=bar --foo='.escapeshellarg(
'b a z').
' --lala Foo '.escapeshellarg(
"A\nB'C"), (
string) $input);