14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \Console \Application ;
16
16
use Symfony \Component \Console \CI \GithubActionReporter ;
17
+ use Symfony \Component \Console \Command \Command ;
17
18
use Symfony \Component \Console \Output \OutputInterface ;
19
+ use Symfony \Component \Console \Tester \CommandCompletionTester ;
18
20
use Symfony \Component \Console \Tester \CommandTester ;
19
21
use Symfony \Component \Yaml \Command \LintCommand ;
20
22
@@ -163,6 +165,21 @@ public function testLintFileNotReadable()
163
165
$ tester ->execute (['filename ' => $ filename ], ['decorated ' => false ]);
164
166
}
165
167
168
+ /**
169
+ * @dataProvider provideCompletionSuggestions
170
+ */
171
+ public function testComplete (array $ input , array $ expectedSuggestions )
172
+ {
173
+ $ tester = new CommandCompletionTester ($ this ->createCommand ());
174
+
175
+ $ this ->assertSame ($ expectedSuggestions , $ tester ->complete ($ input ));
176
+ }
177
+
178
+ public function provideCompletionSuggestions ()
179
+ {
180
+ yield 'option ' => [['--format ' , '' ], ['txt ' , 'json ' , 'github ' ]];
181
+ }
182
+
166
183
private function createFile ($ content ): string
167
184
{
168
185
$ filename = tempnam (sys_get_temp_dir ().'/framework-yml-lint-test ' , 'sf- ' );
@@ -173,13 +190,17 @@ private function createFile($content): string
173
190
return $ filename ;
174
191
}
175
192
176
- protected function createCommandTester (): CommandTester
193
+ protected function createCommand (): Command
177
194
{
178
195
$ application = new Application ();
179
196
$ application ->add (new LintCommand ());
180
- $ command = $ application ->find ('lint:yaml ' );
181
197
182
- return new CommandTester ($ command );
198
+ return $ application ->find ('lint:yaml ' );
199
+ }
200
+
201
+ protected function createCommandTester (): CommandTester
202
+ {
203
+ return new CommandTester ($ this ->createCommand ());
183
204
}
184
205
185
206
protected function setUp (): void
0 commit comments