@@ -2439,6 +2439,38 @@ public function testFindAmbiguousHiddenCommands()
24392439 $ application ->find ('t:f ' );
24402440 }
24412441
2442+ public function testDoesNotFindHiddenCommandAsAlternativeIfHelpOptionIsPresent ()
2443+ {
2444+ $ application = new Application ();
2445+ $ application ->setAutoExit (false );
2446+ $ application ->add (new \FooHiddenCommand ());
2447+
2448+ $ tester = new ApplicationTester ($ application );
2449+ $ tester ->setInputs (['yes ' ]);
2450+ $ tester ->run (['command ' => 'foohidden ' , '--help ' => true ]);
2451+
2452+ $ this ->assertStringContainsString ('Command "foohidden" is not defined. ' , $ tester ->getDisplay (true ));
2453+ $ this ->assertStringNotContainsString ('Did you mean ' , $ tester ->getDisplay (true ));
2454+ $ this ->assertStringNotContainsString ('Do you want to run ' , $ tester ->getDisplay (true ));
2455+ $ this ->assertSame (Command::FAILURE , $ tester ->getStatusCode ());
2456+ }
2457+
2458+ public function testsPreservedHelpOptionWhenItsAnAlternative ()
2459+ {
2460+ $ application = new Application ();
2461+ $ application ->setAutoExit (false );
2462+ $ application ->add (new \FoobarCommand ());
2463+
2464+ $ tester = new ApplicationTester ($ application );
2465+ $ tester ->setInputs (['yes ' ]);
2466+ $ tester ->run (['command ' => 'foobarfoo ' , '--help ' => true ]);
2467+
2468+ $ this ->assertStringContainsString ('Command "foobarfoo" is not defined. ' , $ tester ->getDisplay (true ));
2469+ $ this ->assertStringContainsString ('Do you want to run "foobar:foo" instead? ' , $ tester ->getDisplay (true ));
2470+ $ this ->assertStringContainsString ('The foobar:foo command ' , $ tester ->getDisplay (true ));
2471+ $ this ->assertSame (Command::SUCCESS , $ tester ->getStatusCode ());
2472+ }
2473+
24422474 /**
24432475 * Reads the private "signalHandlers" property of the SignalRegistry for assertions.
24442476 */
0 commit comments