@@ -1018,6 +1018,38 @@ public function testTraversableAutocomplete()
1018
1018
$ this ->assertEquals ('FooBundle ' , $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ inputStream ), $ this ->createOutputInterface (), $ question ));
1019
1019
}
1020
1020
1021
+ public function testTraversableMultiselectAutocomplete ()
1022
+ {
1023
+ // Test cases:
1024
+ // 1) default; 2) Tab single; 3) Traverse and tab multiple; 4) Backspace and traverse multiple; 5) Backspace all
1025
+
1026
+ // <NEWLINE>
1027
+ // F<TAB><NEWLINE>
1028
+ // A<3x UP ARROW><TAB>,F<TAB><NEWLINE>
1029
+ // F00<BACKSPACE><BACKSPACE>o<TAB>,A<DOWN ARROW>,<SPACE>SecurityBundle<NEWLINE>
1030
+ // Acme<TAB> ,<SPACE>As<TAB><29x BACKSPACE>S<TAB><NEWLINE>
1031
+ $ inputStream = $ this ->getInputStream ("\nF \t\nA \033[A \033[A \033[A \t,F \t\nF00 \177\177o \t,A \033[B \t, SecurityBundle \nAcme \t, As \t\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177S \t\n" );
1032
+
1033
+ $ dialog = new QuestionHelper ();
1034
+ $ helperSet = new HelperSet ([new FormatterHelper ()]);
1035
+ $ dialog ->setHelperSet ($ helperSet );
1036
+
1037
+ $ question = new ChoiceQuestion (
1038
+ 'Please select a bundle (defaults to AcmeDemoBundle and AsseticBundle) ' ,
1039
+ ['AcmeDemoBundle ' , 'AsseticBundle ' , 'SecurityBundle ' , 'FooBundle ' ],
1040
+ '0,1 '
1041
+ );
1042
+
1043
+ // This tests that autocomplete works for all multiselect choices entered by the user
1044
+ $ question ->setMultiselect (true );
1045
+
1046
+ $ this ->assertEquals (['AcmeDemoBundle ' , 'AsseticBundle ' ], $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ inputStream ), $ this ->createOutputInterface (), $ question ));
1047
+ $ this ->assertEquals (['FooBundle ' ], $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ inputStream ), $ this ->createOutputInterface (), $ question ));
1048
+ $ this ->assertEquals (['AsseticBundle ' , 'FooBundle ' ], $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ inputStream ), $ this ->createOutputInterface (), $ question ));
1049
+ $ this ->assertEquals (['FooBundle ' , 'AsseticBundle ' , 'SecurityBundle ' ], $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ inputStream ), $ this ->createOutputInterface (), $ question ));
1050
+ $ this ->assertEquals (['SecurityBundle ' ], $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ inputStream ), $ this ->createOutputInterface (), $ question ));
1051
+ }
1052
+
1021
1053
protected function getInputStream ($ input )
1022
1054
{
1023
1055
$ stream = fopen ('php://memory ' , 'r+ ' , false );
0 commit comments