12 namespace Symfony\Component\Console\Tests\Input;
26 $r = new \ReflectionClass(
'Symfony\Component\Console\Input\ArgvInput');
27 $p = $r->getProperty(
'tokens');
28 $p->setAccessible(
true);
29 $this->assertEquals($tokens, $p->getValue($input), $message);
40 $input->bind($definition);
41 $this->assertEquals(
'bar', $input->getOption(
'foo'));
54 $this->assertEquals(
'bar', $input->getOption(
'foo'));
60 array(
'', array(),
'->tokenize() parses an empty string'),
61 array(
'foo', array(
'foo'),
'->tokenize() parses arguments'),
62 array(
' foo bar ', array(
'foo',
'bar'),
'->tokenize() ignores whitespaces between arguments'),
63 array(
'"quoted"', array(
'quoted'),
'->tokenize() parses quoted arguments'),
64 array(
"'quoted'", array(
'quoted'),
'->tokenize() parses quoted arguments'),
65 array(
"'a\rb\nc\td'", array(
"a\rb\nc\td"),
'->tokenize() parses whitespace chars in strings'),
66 array(
"'a'\r'b'\n'c'\t'd'", array(
'a',
'b',
'c',
'd'),
'->tokenize() parses whitespace chars between args as spaces'),
67 array(
'\"quoted\"', array(
'"quoted"'),
'->tokenize() parses escaped-quoted arguments'),
68 array(
"\'quoted\'", array(
'\'quoted\
''),
'->tokenize() parses escaped-quoted arguments'),
69 array(
'-a', array(
'-a'),
'->tokenize() parses short options'),
70 array(
'-azc', array(
'-azc'),
'->tokenize() parses aggregated short options'),
71 array(
'-awithavalue', array(
'-awithavalue'),
'->tokenize() parses short options with a value'),
72 array(
'-a"foo bar"', array(
'-afoo bar'),
'->tokenize() parses short options with a value'),
73 array(
'-a"foo bar""foo bar"', array(
'-afoo barfoo bar'),
'->tokenize() parses short options with a value'),
74 array(
'-a\'foo bar\'', array(
'-afoo bar'),
'->tokenize() parses short options with a value'),
75 array(
'-a\'foo bar\'\'foo bar\'', array(
'-afoo barfoo bar'),
'->tokenize() parses short options with a value'),
76 array(
'-a\'foo bar\'"foo bar"', array(
'-afoo barfoo bar'),
'->tokenize() parses short options with a value'),
77 array(
'--long-option', array(
'--long-option'),
'->tokenize() parses long options'),
78 array(
'--long-option=foo', array(
'--long-option=foo'),
'->tokenize() parses long options with a value'),
79 array(
'--long-option="foo bar"', array(
'--long-option=foo bar'),
'->tokenize() parses long options with a value'),
80 array(
'--long-option="foo bar""another"', array(
'--long-option=foo baranother'),
'->tokenize() parses long options with a value'),
81 array(
'--long-option=\'foo bar\'', array(
'--long-option=foo bar'),
'->tokenize() parses long options with a value'),
82 array(
"--long-option='foo bar''another'", array(
'--long-option=foo baranother'),
'->tokenize() parses long options with a value'),
83 array(
"--long-option='foo bar'\"another\"", array(
'--long-option=foo baranother'),
'->tokenize() parses long options with a value'),
84 array(
'foo -a -ffoo --long bar', array(
'foo',
'-a',
'-ffoo',
'--long',
'bar'),
'->tokenize() parses when several arguments and options'),
91 $this->assertEquals(
'-f foo', (
string) $input);
94 $this->assertEquals(
'-f --bar=foo '.escapeshellarg(
'a b c d'), (
string) $input);
96 $input =
new StringInput(
'-f --bar=foo \'a b c d\' '.
"'A\nB\\'C'");
97 $this->assertEquals(
'-f --bar=foo '.escapeshellarg(
'a b c d').
' '.escapeshellarg(
"A\nB'C"), (
string) $input);