@@ -2439,6 +2439,35 @@ 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 ->run (['command ' => 'foohidden ' , '--help ' => true ], ['interactive ' => false ]);
2450+
2451+ $ this ->assertStringContainsString ('Command "foohidden" is not defined. ' , $ tester ->getDisplay (true ));
2452+ $ this ->assertStringNotContainsString ('Did you mean ' , $ tester ->getDisplay (true ));
2453+ $ this ->assertStringNotContainsString ('Do you want to run ' , $ tester ->getDisplay (true ));
2454+ }
2455+
2456+ public function testsPreservedHelpOptionWhenItsAnAlternative ()
2457+ {
2458+ $ application = new Application ();
2459+ $ application ->setAutoExit (false );
2460+ $ application ->add (new \FoobarCommand ());
2461+
2462+ $ tester = new ApplicationTester ($ application );
2463+ $ tester ->setInputs (['yes ' ]);
2464+ $ tester ->run (['command ' => 'foobarfoo ' , '--help ' => true ]);
2465+
2466+ $ this ->assertStringContainsString ('Command "foobarfoo" is not defined. ' , $ tester ->getDisplay (true ));
2467+ $ this ->assertStringContainsString ('Do you want to run "foobar:foo" instead? ' , $ tester ->getDisplay (true ));
2468+ $ this ->assertStringContainsString ('The foobar:foo command ' , $ tester ->getDisplay (true ));
2469+ }
2470+
24422471 /**
24432472 * Reads the private "signalHandlers" property of the SignalRegistry for assertions.
24442473 */
0 commit comments