File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -389,10 +389,7 @@ public function getDefinition(): InputDefinition
389389 $ this ->definition ??= $ this ->getDefaultInputDefinition ();
390390
391391 if ($ this ->singleCommand ) {
392- $ inputDefinition = $ this ->definition ;
393- $ inputDefinition ->setArguments ();
394-
395- return $ inputDefinition ;
392+ $ this ->definition ->setArguments ();
396393 }
397394
398395 return $ this ->definition ;
Original file line number Diff line number Diff line change @@ -1480,6 +1480,31 @@ public function testSettingCustomInputDefinitionOverwritesDefaultValues()
14801480 $ this ->assertTrue ($ inputDefinition ->hasOption ('custom ' ));
14811481 }
14821482
1483+ public function testItRemovesArgumentsFromInputDefinitionOnSingleCommandApplication ()
1484+ {
1485+ $ application = new Application ();
1486+ $ application ->setAutoExit (false );
1487+ $ application ->setCatchExceptions (false );
1488+
1489+ $ application ->setDefaultCommand ('list ' , true ); // It's a single command application.
1490+
1491+ $ inputDefinition = $ application ->getDefinition ();
1492+
1493+ // $inputDefinition->setArguments() is called to remove default arguments.
1494+ $ this ->assertSame (0 , $ inputDefinition ->getArgumentCount ());
1495+ $ this ->assertFalse ($ inputDefinition ->hasArgument ('command ' ));
1496+
1497+ // $inputDefinition->setOptions() is not called to leave default options as they are.
1498+ $ this ->assertTrue ($ inputDefinition ->hasOption ('help ' ));
1499+ $ this ->assertTrue ($ inputDefinition ->hasOption ('quiet ' ));
1500+ $ this ->assertTrue ($ inputDefinition ->hasOption ('verbose ' ));
1501+ $ this ->assertTrue ($ inputDefinition ->hasOption ('version ' ));
1502+ $ this ->assertTrue ($ inputDefinition ->hasOption ('ansi ' ));
1503+ $ this ->assertTrue ($ inputDefinition ->hasNegation ('no-ansi ' ));
1504+ $ this ->assertFalse ($ inputDefinition ->hasOption ('no-ansi ' ));
1505+ $ this ->assertTrue ($ inputDefinition ->hasOption ('no-interaction ' ));
1506+ }
1507+
14831508 public function testRunWithDispatcher ()
14841509 {
14851510 $ application = new Application ();
You can’t perform that action at this time.
0 commit comments