|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Psr\Log\NullLogger;
|
| 16 | +use Symfony\Bundle\FrameworkBundle\Console\Application; |
16 | 17 | use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
| 18 | +use Symfony\Component\Console\Attribute\AsCommand; |
| 19 | +use Symfony\Component\Console\Input\ArrayInput; |
| 20 | +use Symfony\Component\Console\Output\BufferedOutput; |
17 | 21 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
18 | 22 | use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
19 | 23 | use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
@@ -152,6 +156,23 @@ public function testSimpleKernel()
|
152 | 156 | $this->assertSame('Hello World!', $response->getContent());
|
153 | 157 | }
|
154 | 158 |
|
| 159 | + public function testKernelCommand() |
| 160 | + { |
| 161 | + if (!property_exists(AsCommand::class, 'help')) { |
| 162 | + $this->markTestSkipped('Invokable command no available.'); |
| 163 | + } |
| 164 | + |
| 165 | + $kernel = $this->kernel = new KernelCommand('kernel_command'); |
| 166 | + $application = new Application($kernel); |
| 167 | + |
| 168 | + $input = new ArrayInput(['command' => 'kernel:hello']); |
| 169 | + $output = new BufferedOutput(); |
| 170 | + |
| 171 | + $this->assertTrue($application->has('kernel:hello')); |
| 172 | + $this->assertSame(0, $application->doRun($input, $output)); |
| 173 | + $this->assertSame('Hello Kernel!', $output->fetch()); |
| 174 | + } |
| 175 | + |
155 | 176 | public function testDefaultKernel()
|
156 | 177 | {
|
157 | 178 | $kernel = $this->kernel = new DefaultKernel('test', false);
|
|
0 commit comments