@@ -156,6 +156,46 @@ public function testAskWithAutocompleteWithNonSequentialKeys()
156
156
$ this ->assertEquals ('AsseticBundle ' , $ dialog ->ask ($ this ->createInputInterfaceMock (), $ this ->createOutputInterface (), $ question ));
157
157
}
158
158
159
+ public function testAutocompleteWithTrailingBackslash ()
160
+ {
161
+ if (!$ this ->hasSttyAvailable ()) {
162
+ $ this ->markTestSkipped ('`stty` is required to test autocomplete functionality ' );
163
+ }
164
+
165
+ $ inputStream = $ this ->getInputStream ('E ' );
166
+
167
+ $ dialog = new QuestionHelper ();
168
+ $ dialog ->setInputStream ($ inputStream );
169
+ $ helperSet = new HelperSet (array (new FormatterHelper ()));
170
+ $ dialog ->setHelperSet ($ helperSet );
171
+
172
+ $ question = new Question ('' );
173
+ $ expectedCompletion = 'ExampleNamespace \\' ;
174
+ $ question ->setAutocompleterValues (array ($ expectedCompletion ));
175
+
176
+ $ output = $ this ->createOutputInterface ();
177
+ $ dialog ->ask ($ this ->createInputInterfaceMock (), $ output , $ question );
178
+
179
+ $ outputStream = $ output ->getStream ();
180
+ rewind ($ outputStream );
181
+ $ actualOutput = stream_get_contents ($ outputStream );
182
+
183
+ // Shell control (esc) sequences are not so important: we only care that
184
+ // <hl> tag is interpreted correctly and replaced
185
+ $ irrelevantEscSequences = array (
186
+ "\0337 " => '' , // Save cursor position
187
+ "\0338 " => '' , // Restore cursor position
188
+ "\033[K " => '' , // Clear line from cursor till the end
189
+ );
190
+
191
+ $ importantActualOutput = strtr ($ actualOutput , $ irrelevantEscSequences );
192
+
193
+ // Remove colors (e.g. "\033[30m", "\033[31;41m")
194
+ $ importantActualOutput = preg_replace ('/\033\[\d+(;\d+)?m/ ' , '' , $ importantActualOutput );
195
+
196
+ $ this ->assertEquals ($ expectedCompletion , $ importantActualOutput );
197
+ }
198
+
159
199
public function testAskHiddenResponse ()
160
200
{
161
201
if ('\\' === DIRECTORY_SEPARATOR ) {
0 commit comments