|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
13 | 13 |
|
14 | 14 | use Symfony\Bundle\FrameworkBundle\Console\Application;
|
| 15 | +use Symfony\Component\Console\Tester\CommandCompletionTester; |
15 | 16 | use Symfony\Component\Console\Tester\CommandTester;
|
16 | 17 |
|
17 | 18 | /**
|
@@ -69,6 +70,37 @@ public function testSearchWithThrow()
|
69 | 70 | $tester->execute(['name' => 'gerard'], ['interactive' => true]);
|
70 | 71 | }
|
71 | 72 |
|
| 73 | + /** |
| 74 | + * @dataProvider provideCompletionSuggestions |
| 75 | + */ |
| 76 | + public function testComplete(array $input, array $expectedSuggestions) |
| 77 | + { |
| 78 | + if (!class_exists(CommandCompletionTester::class)) { |
| 79 | + $this->markTestSkipped('Test command completion requires symfony/console 5.4+.'); |
| 80 | + } |
| 81 | + |
| 82 | + $tester = new CommandCompletionTester($this->application->get('debug:router')); |
| 83 | + $this->assertSame($expectedSuggestions, $tester->complete($input)); |
| 84 | + } |
| 85 | + |
| 86 | + public function provideCompletionSuggestions() |
| 87 | + { |
| 88 | + yield 'option --format' => [ |
| 89 | + ['--format', ''], |
| 90 | + ['txt', 'xml', 'json', 'md'], |
| 91 | + ]; |
| 92 | + |
| 93 | + yield 'route_name' => [ |
| 94 | + [''], |
| 95 | + [ |
| 96 | + 'routerdebug_session_welcome', |
| 97 | + 'routerdebug_session_welcome_name', |
| 98 | + 'routerdebug_session_logout', |
| 99 | + 'routerdebug_test', |
| 100 | + ], |
| 101 | + ]; |
| 102 | + } |
| 103 | + |
72 | 104 | private function createCommandTester(): CommandTester
|
73 | 105 | {
|
74 | 106 | $command = $this->application->get('debug:router');
|
|
0 commit comments