ArgvInputTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Tests\Input;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Console\Input\ArgvInput;
  13. use Symfony\Component\Console\Input\InputArgument;
  14. use Symfony\Component\Console\Input\InputDefinition;
  15. use Symfony\Component\Console\Input\InputOption;
  16. class ArgvInputTest extends TestCase
  17. {
  18. public function testConstructor()
  19. {
  20. $_SERVER['argv'] = ['cli.php', 'foo'];
  21. $input = new ArgvInput();
  22. $r = new \ReflectionObject($input);
  23. $p = $r->getProperty('tokens');
  24. $p->setAccessible(true);
  25. $this->assertEquals(['foo'], $p->getValue($input), '__construct() automatically get its input from the argv server variable');
  26. }
  27. public function testParseArguments()
  28. {
  29. $input = new ArgvInput(['cli.php', 'foo']);
  30. $input->bind(new InputDefinition([new InputArgument('name')]));
  31. $this->assertEquals(['name' => 'foo'], $input->getArguments(), '->parse() parses required arguments');
  32. $input->bind(new InputDefinition([new InputArgument('name')]));
  33. $this->assertEquals(['name' => 'foo'], $input->getArguments(), '->parse() is stateless');
  34. }
  35. /**
  36. * @dataProvider provideOptions
  37. */
  38. public function testParseOptions($input, $options, $expectedOptions, $message)
  39. {
  40. $input = new ArgvInput($input);
  41. $input->bind(new InputDefinition($options));
  42. $this->assertSame($expectedOptions, $input->getOptions(), $message);
  43. }
  44. public function provideOptions()
  45. {
  46. return [
  47. [
  48. ['cli.php', '--foo'],
  49. [new InputOption('foo')],
  50. ['foo' => true],
  51. '->parse() parses long options without a value',
  52. ],
  53. [
  54. ['cli.php', '--foo=bar'],
  55. [new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)],
  56. ['foo' => 'bar'],
  57. '->parse() parses long options with a required value (with a = separator)',
  58. ],
  59. [
  60. ['cli.php', '--foo', 'bar'],
  61. [new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)],
  62. ['foo' => 'bar'],
  63. '->parse() parses long options with a required value (with a space separator)',
  64. ],
  65. [
  66. ['cli.php', '--foo='],
  67. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)],
  68. ['foo' => ''],
  69. '->parse() parses long options with optional value which is empty (with a = separator) as empty string',
  70. ],
  71. [
  72. ['cli.php', '--foo=', 'bar'],
  73. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)],
  74. ['foo' => ''],
  75. '->parse() parses long options with optional value without value specified or an empty string (with a = separator) followed by an argument as empty string',
  76. ],
  77. [
  78. ['cli.php', 'bar', '--foo'],
  79. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)],
  80. ['foo' => null],
  81. '->parse() parses long options with optional value which is empty (with a = separator) preceded by an argument',
  82. ],
  83. [
  84. ['cli.php', '--foo', '', 'bar'],
  85. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)],
  86. ['foo' => ''],
  87. '->parse() parses long options with optional value which is empty as empty string even followed by an argument',
  88. ],
  89. [
  90. ['cli.php', '--foo'],
  91. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)],
  92. ['foo' => null],
  93. '->parse() parses long options with optional value specified with no separator and no value as null',
  94. ],
  95. [
  96. ['cli.php', '-f'],
  97. [new InputOption('foo', 'f')],
  98. ['foo' => true],
  99. '->parse() parses short options without a value',
  100. ],
  101. [
  102. ['cli.php', '-fbar'],
  103. [new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)],
  104. ['foo' => 'bar'],
  105. '->parse() parses short options with a required value (with no separator)',
  106. ],
  107. [
  108. ['cli.php', '-f', 'bar'],
  109. [new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)],
  110. ['foo' => 'bar'],
  111. '->parse() parses short options with a required value (with a space separator)',
  112. ],
  113. [
  114. ['cli.php', '-f', ''],
  115. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)],
  116. ['foo' => ''],
  117. '->parse() parses short options with an optional empty value',
  118. ],
  119. [
  120. ['cli.php', '-f', '', 'foo'],
  121. [new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)],
  122. ['foo' => ''],
  123. '->parse() parses short options with an optional empty value followed by an argument',
  124. ],
  125. [
  126. ['cli.php', '-f', '', '-b'],
  127. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')],
  128. ['foo' => '', 'bar' => true],
  129. '->parse() parses short options with an optional empty value followed by an option',
  130. ],
  131. [
  132. ['cli.php', '-f', '-b', 'foo'],
  133. [new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')],
  134. ['foo' => null, 'bar' => true],
  135. '->parse() parses short options with an optional value which is not present',
  136. ],
  137. [
  138. ['cli.php', '-fb'],
  139. [new InputOption('foo', 'f'), new InputOption('bar', 'b')],
  140. ['foo' => true, 'bar' => true],
  141. '->parse() parses short options when they are aggregated as a single one',
  142. ],
  143. [
  144. ['cli.php', '-fb', 'bar'],
  145. [new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)],
  146. ['foo' => true, 'bar' => 'bar'],
  147. '->parse() parses short options when they are aggregated as a single one and the last one has a required value',
  148. ],
  149. [
  150. ['cli.php', '-fb', 'bar'],
  151. [new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)],
  152. ['foo' => true, 'bar' => 'bar'],
  153. '->parse() parses short options when they are aggregated as a single one and the last one has an optional value',
  154. ],
  155. [
  156. ['cli.php', '-fbbar'],
  157. [new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)],
  158. ['foo' => true, 'bar' => 'bar'],
  159. '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator',
  160. ],
  161. [
  162. ['cli.php', '-fbbar'],
  163. [new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)],
  164. ['foo' => 'bbar', 'bar' => null],
  165. '->parse() parses short options when they are aggregated as a single one and one of them takes a value',
  166. ],
  167. ];
  168. }
  169. /**
  170. * @dataProvider provideInvalidInput
  171. */
  172. public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
  173. {
  174. $this->expectException('RuntimeException');
  175. $this->expectExceptionMessage($expectedExceptionMessage);
  176. $input = new ArgvInput($argv);
  177. $input->bind($definition);
  178. }
  179. public function provideInvalidInput()
  180. {
  181. return [
  182. [
  183. ['cli.php', '--foo'],
  184. new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)]),
  185. 'The "--foo" option requires a value.',
  186. ],
  187. [
  188. ['cli.php', '-f'],
  189. new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)]),
  190. 'The "--foo" option requires a value.',
  191. ],
  192. [
  193. ['cli.php', '-ffoo'],
  194. new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NONE)]),
  195. 'The "-o" option does not exist.',
  196. ],
  197. [
  198. ['cli.php', '--foo=bar'],
  199. new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NONE)]),
  200. 'The "--foo" option does not accept a value.',
  201. ],
  202. [
  203. ['cli.php', 'foo', 'bar'],
  204. new InputDefinition(),
  205. 'No arguments expected, got "foo".',
  206. ],
  207. [
  208. ['cli.php', 'foo', 'bar'],
  209. new InputDefinition([new InputArgument('number')]),
  210. 'Too many arguments, expected arguments "number".',
  211. ],
  212. [
  213. ['cli.php', 'foo', 'bar', 'zzz'],
  214. new InputDefinition([new InputArgument('number'), new InputArgument('county')]),
  215. 'Too many arguments, expected arguments "number" "county".',
  216. ],
  217. [
  218. ['cli.php', '--foo'],
  219. new InputDefinition(),
  220. 'The "--foo" option does not exist.',
  221. ],
  222. [
  223. ['cli.php', '-f'],
  224. new InputDefinition(),
  225. 'The "-f" option does not exist.',
  226. ],
  227. [
  228. ['cli.php', '-1'],
  229. new InputDefinition([new InputArgument('number')]),
  230. 'The "-1" option does not exist.',
  231. ],
  232. [
  233. ['cli.php', '-fЩ'],
  234. new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_NONE)]),
  235. 'The "-Щ" option does not exist.',
  236. ],
  237. ];
  238. }
  239. public function testParseArrayArgument()
  240. {
  241. $input = new ArgvInput(['cli.php', 'foo', 'bar', 'baz', 'bat']);
  242. $input->bind(new InputDefinition([new InputArgument('name', InputArgument::IS_ARRAY)]));
  243. $this->assertEquals(['name' => ['foo', 'bar', 'baz', 'bat']], $input->getArguments(), '->parse() parses array arguments');
  244. }
  245. public function testParseArrayOption()
  246. {
  247. $input = new ArgvInput(['cli.php', '--name=foo', '--name=bar', '--name=baz']);
  248. $input->bind(new InputDefinition([new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)]));
  249. $this->assertEquals(['name' => ['foo', 'bar', 'baz']], $input->getOptions(), '->parse() parses array options ("--option=value" syntax)');
  250. $input = new ArgvInput(['cli.php', '--name', 'foo', '--name', 'bar', '--name', 'baz']);
  251. $input->bind(new InputDefinition([new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)]));
  252. $this->assertEquals(['name' => ['foo', 'bar', 'baz']], $input->getOptions(), '->parse() parses array options ("--option value" syntax)');
  253. $input = new ArgvInput(['cli.php', '--name=foo', '--name=bar', '--name=']);
  254. $input->bind(new InputDefinition([new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)]));
  255. $this->assertSame(['name' => ['foo', 'bar', '']], $input->getOptions(), '->parse() parses empty array options as null ("--option=value" syntax)');
  256. $input = new ArgvInput(['cli.php', '--name', 'foo', '--name', 'bar', '--name', '--anotherOption']);
  257. $input->bind(new InputDefinition([
  258. new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY),
  259. new InputOption('anotherOption', null, InputOption::VALUE_NONE),
  260. ]));
  261. $this->assertSame(['name' => ['foo', 'bar', null], 'anotherOption' => true], $input->getOptions(), '->parse() parses empty array options ("--option value" syntax)');
  262. }
  263. public function testParseNegativeNumberAfterDoubleDash()
  264. {
  265. $input = new ArgvInput(['cli.php', '--', '-1']);
  266. $input->bind(new InputDefinition([new InputArgument('number')]));
  267. $this->assertEquals(['number' => '-1'], $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence');
  268. $input = new ArgvInput(['cli.php', '-f', 'bar', '--', '-1']);
  269. $input->bind(new InputDefinition([new InputArgument('number'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)]));
  270. $this->assertEquals(['foo' => 'bar'], $input->getOptions(), '->parse() parses arguments with leading dashes as options before having encountered a double-dash sequence');
  271. $this->assertEquals(['number' => '-1'], $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence');
  272. }
  273. public function testParseEmptyStringArgument()
  274. {
  275. $input = new ArgvInput(['cli.php', '-f', 'bar', '']);
  276. $input->bind(new InputDefinition([new InputArgument('empty'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)]));
  277. $this->assertEquals(['empty' => ''], $input->getArguments(), '->parse() parses empty string arguments');
  278. }
  279. public function testGetFirstArgument()
  280. {
  281. $input = new ArgvInput(['cli.php', '-fbbar']);
  282. $this->assertNull($input->getFirstArgument(), '->getFirstArgument() returns null when there is no arguments');
  283. $input = new ArgvInput(['cli.php', '-fbbar', 'foo']);
  284. $this->assertEquals('foo', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input');
  285. $input = new ArgvInput(['cli.php', '--foo', 'fooval', 'bar']);
  286. $input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('arg')]));
  287. $this->assertSame('bar', $input->getFirstArgument());
  288. $input = new ArgvInput(['cli.php', '-bf', 'fooval', 'argval']);
  289. $input->bind(new InputDefinition([new InputOption('bar', 'b', InputOption::VALUE_NONE), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('arg')]));
  290. $this->assertSame('argval', $input->getFirstArgument());
  291. }
  292. public function testHasParameterOption()
  293. {
  294. $input = new ArgvInput(['cli.php', '-f', 'foo']);
  295. $this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
  296. $input = new ArgvInput(['cli.php', '-etest']);
  297. $this->assertTrue($input->hasParameterOption('-e'), '->hasParameterOption() returns true if the given short option is in the raw input');
  298. $this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
  299. $input = new ArgvInput(['cli.php', '--foo', 'foo']);
  300. $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
  301. $input = new ArgvInput(['cli.php', 'foo']);
  302. $this->assertFalse($input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input');
  303. $input = new ArgvInput(['cli.php', '--foo=bar']);
  304. $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given option with provided value is in the raw input');
  305. }
  306. public function testHasParameterOptionOnlyOptions()
  307. {
  308. $input = new ArgvInput(['cli.php', '-f', 'foo']);
  309. $this->assertTrue($input->hasParameterOption('-f', true), '->hasParameterOption() returns true if the given short option is in the raw input');
  310. $input = new ArgvInput(['cli.php', '--foo', '--', 'foo']);
  311. $this->assertTrue($input->hasParameterOption('--foo', true), '->hasParameterOption() returns true if the given long option is in the raw input');
  312. $input = new ArgvInput(['cli.php', '--foo=bar', 'foo']);
  313. $this->assertTrue($input->hasParameterOption('--foo', true), '->hasParameterOption() returns true if the given long option with provided value is in the raw input');
  314. $input = new ArgvInput(['cli.php', '--', '--foo']);
  315. $this->assertFalse($input->hasParameterOption('--foo', true), '->hasParameterOption() returns false if the given option is in the raw input but after an end of options signal');
  316. }
  317. public function testHasParameterOptionEdgeCasesAndLimitations()
  318. {
  319. $input = new ArgvInput(['cli.php', '-fh']);
  320. // hasParameterOption does not know if the previous short option, -f,
  321. // takes a value or not. If -f takes a value, then -fh does NOT include
  322. // -h; Otherwise it does. Since we do not know which short options take
  323. // values, hasParameterOption does not support this use-case.
  324. $this->assertFalse($input->hasParameterOption('-h'), '->hasParameterOption() returns true if the given short option is in the raw input');
  325. // hasParameterOption does detect that `-fh` contains `-f`, since
  326. // `-f` is the first short option in the set.
  327. $this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
  328. // The test below happens to pass, although it might make more sense
  329. // to disallow it, and require the use of
  330. // $input->hasParameterOption('-f') && $input->hasParameterOption('-h')
  331. // instead.
  332. $this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
  333. // In theory, if -fh is supported, then -hf should also work.
  334. // However, this is not supported.
  335. $this->assertFalse($input->hasParameterOption('-hf'), '->hasParameterOption() returns true if the given short option is in the raw input');
  336. $input = new ArgvInput(['cli.php', '-f', '-h']);
  337. // If hasParameterOption('-fh') is supported for 'cli.php -fh', then
  338. // one might also expect that it should also be supported for
  339. // 'cli.php -f -h'. However, this is not supported.
  340. $this->assertFalse($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
  341. }
  342. public function testNoWarningOnInvalidParameterOption()
  343. {
  344. $input = new ArgvInput(['cli.php', '-edev']);
  345. $this->assertTrue($input->hasParameterOption(['-e', '']));
  346. // No warning thrown
  347. $this->assertFalse($input->hasParameterOption(['-m', '']));
  348. $this->assertEquals('dev', $input->getParameterOption(['-e', '']));
  349. // No warning thrown
  350. $this->assertFalse($input->getParameterOption(['-m', '']));
  351. }
  352. public function testToString()
  353. {
  354. $input = new ArgvInput(['cli.php', '-f', 'foo']);
  355. $this->assertEquals('-f foo', (string) $input);
  356. $input = new ArgvInput(['cli.php', '-f', '--bar=foo', 'a b c d', "A\nB'C"]);
  357. $this->assertEquals('-f --bar=foo '.escapeshellarg('a b c d').' '.escapeshellarg("A\nB'C"), (string) $input);
  358. }
  359. /**
  360. * @dataProvider provideGetParameterOptionValues
  361. */
  362. public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyParams, $expected)
  363. {
  364. $input = new ArgvInput($argv);
  365. $this->assertEquals($expected, $input->getParameterOption($key, $default, $onlyParams), '->getParameterOption() returns the expected value');
  366. }
  367. public function provideGetParameterOptionValues()
  368. {
  369. return [
  370. [['app/console', 'foo:bar'], '-e', 'default', false, 'default'],
  371. [['app/console', 'foo:bar', '-e', 'dev'], '-e', 'default', false, 'dev'],
  372. [['app/console', 'foo:bar', '--env=dev'], '--env', 'default', false, 'dev'],
  373. [['app/console', 'foo:bar', '-e', 'dev'], ['-e', '--env'], 'default', false, 'dev'],
  374. [['app/console', 'foo:bar', '--env=dev'], ['-e', '--env'], 'default', false, 'dev'],
  375. [['app/console', 'foo:bar', '--env=dev', '--en=1'], ['--en'], 'default', false, '1'],
  376. [['app/console', 'foo:bar', '--env=dev', '', '--en=1'], ['--en'], 'default', false, '1'],
  377. [['app/console', 'foo:bar', '--env', 'val'], '--env', 'default', false, 'val'],
  378. [['app/console', 'foo:bar', '--env', 'val', '--dummy'], '--env', 'default', false, 'val'],
  379. [['app/console', 'foo:bar', '--', '--env=dev'], '--env', 'default', false, 'dev'],
  380. [['app/console', 'foo:bar', '--', '--env=dev'], '--env', 'default', true, 'default'],
  381. ];
  382. }
  383. public function testParseSingleDashAsArgument()
  384. {
  385. $input = new ArgvInput(['cli.php', '-']);
  386. $input->bind(new InputDefinition([new InputArgument('file')]));
  387. $this->assertEquals(['file' => '-'], $input->getArguments(), '->parse() parses single dash as an argument');
  388. }
  389. public function testParseOptionWithValueOptionalGivenEmptyAndRequiredArgument()
  390. {
  391. $input = new ArgvInput(['cli.php', '--foo=', 'bar']);
  392. $input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)]));
  393. $this->assertEquals(['foo' => null], $input->getOptions(), '->parse() parses optional options with empty value as null');
  394. $this->assertEquals(['name' => 'bar'], $input->getArguments(), '->parse() parses required arguments');
  395. $input = new ArgvInput(['cli.php', '--foo=0', 'bar']);
  396. $input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)]));
  397. $this->assertEquals(['foo' => '0'], $input->getOptions(), '->parse() parses optional options with empty value as null');
  398. $this->assertEquals(['name' => 'bar'], $input->getArguments(), '->parse() parses required arguments');
  399. }
  400. public function testParseOptionWithValueOptionalGivenEmptyAndOptionalArgument()
  401. {
  402. $input = new ArgvInput(['cli.php', '--foo=', 'bar']);
  403. $input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::OPTIONAL)]));
  404. $this->assertEquals(['foo' => null], $input->getOptions(), '->parse() parses optional options with empty value as null');
  405. $this->assertEquals(['name' => 'bar'], $input->getArguments(), '->parse() parses optional arguments');
  406. $input = new ArgvInput(['cli.php', '--foo=0', 'bar']);
  407. $input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::OPTIONAL)]));
  408. $this->assertEquals(['foo' => '0'], $input->getOptions(), '->parse() parses optional options with empty value as null');
  409. $this->assertEquals(['name' => 'bar'], $input->getArguments(), '->parse() parses optional arguments');
  410. }
  411. }