File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ class DummyDto
5656 public Arg2 $ arg2 ;
5757
5858 #[Argument]
59- #[Ask('Enter arg3 ' , hidden: true )]
59+ #[Ask('Enter arg3 ' )]
6060 public string $ arg3 ;
6161
6262 #[Argument]
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \Console \Tests \Fixtures ;
13+
14+ use Symfony \Component \Console \Attribute \Argument ;
15+ use Symfony \Component \Console \Attribute \AsCommand ;
16+ use Symfony \Component \Console \Attribute \Ask ;
17+ use Symfony \Component \Console \Attribute \MapInput ;
18+ use Symfony \Component \Console \Command \Command ;
19+ use Symfony \Component \Console \Style \SymfonyStyle ;
20+
21+ #[AsCommand('invokable:interactive:question ' )]
22+ class InvokableWithInteractiveHiddenQuestionAttributeTestCommand
23+ {
24+ public function __invoke (
25+ SymfonyStyle $ io ,
26+ #[MapInput] DtoWithHiddenQuestionArg $ dto ,
27+ ): int {
28+ $ io ->writeln ('Arg1: ' .$ dto ->arg1 );
29+
30+ return Command::SUCCESS ;
31+ }
32+ }
33+
34+ class DtoWithHiddenQuestionArg
35+ {
36+ #[Argument]
37+ #[Ask('Enter arg1 ' , hidden: true )]
38+ public string $ arg1 ;
39+ }
Original file line number Diff line number Diff line change 3030use Symfony \Component \Console \Tests \Fixtures \InvokableTestCommand ;
3131use Symfony \Component \Console \Tests \Fixtures \InvokableWithInputTestCommand ;
3232use Symfony \Component \Console \Tests \Fixtures \InvokableWithInteractiveAttributesTestCommand ;
33+ use Symfony \Component \Console \Tests \Fixtures \InvokableWithInteractiveHiddenQuestionAttributeTestCommand ;
3334
3435class CommandTesterTest extends TestCase
3536{
@@ -490,4 +491,19 @@ public function testInvokableWithInteractiveQuestionParameter()
490491 self ::assertStringContainsString ('Enter arg5 ' , $ tester ->getDisplay ());
491492 self ::assertStringContainsString ('Arg5: arg5-value ' , $ tester ->getDisplay ());
492493 }
494+
495+ public function testInvokableWithInteractiveHiddenQuestionParameter ()
496+ {
497+ if ('\\' === \DIRECTORY_SEPARATOR ) {
498+ $ this ->markTestSkipped ('Cannot test hidden questions on Windows ' );
499+ }
500+
501+ $ tester = new CommandTester (new InvokableWithInteractiveHiddenQuestionAttributeTestCommand ());
502+ $ tester ->setInputs (['arg1-value ' ]);
503+ $ tester ->execute ([], ['interactive ' => true ]);
504+ $ tester ->assertCommandIsSuccessful ();
505+
506+ self ::assertStringContainsString ('Enter arg1 ' , $ tester ->getDisplay ());
507+ self ::assertStringContainsString ('Arg1: arg1-value ' , $ tester ->getDisplay ());
508+ }
493509}
You can’t perform that action at this time.
0 commit comments