1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Portiny\Console\Tests\Adapter\Nette\DI; |
4
|
|
|
|
5
|
|
|
use Portiny\Console\Tests\AbstractContainerTestCase; |
6
|
|
|
use Portiny\Console\Tests\Source\PrintRequestUrlCommand; |
7
|
|
|
use Symfony\Component\Console\Application; |
8
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
9
|
|
|
|
10
|
|
|
final class ConsoleExtensionTest extends AbstractContainerTestCase |
11
|
|
|
{ |
12
|
|
|
public function testLoadConfiguration(): void |
13
|
|
|
{ |
14
|
|
|
$application = $this->container->getByType(Application::class); |
15
|
|
|
$this->assertInstanceOf(Application::class, $application); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testBeforeCompile(): void |
19
|
|
|
{ |
20
|
|
|
/** @var Application $application */ |
21
|
|
|
$application = $this->container->getByType(Application::class); |
22
|
|
|
|
23
|
|
|
$this->assertFalse($application->isAutoExitEnabled()); |
24
|
|
|
$this->assertTrue($application->areExceptionsCaught()); |
25
|
|
|
$this->assertCount(3, $application->all()); |
26
|
|
|
$this->assertTrue($application->has('print-request-url')); |
27
|
|
|
$this->assertInstanceOf(PrintRequestUrlCommand::class, $application->get('print-request-url')); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testExecution(): void |
31
|
|
|
{ |
32
|
|
|
/** @var Application $application */ |
33
|
|
|
$application = $this->container->getByType(Application::class); |
34
|
|
|
|
35
|
|
|
$command = $application->find('print-request-url'); |
36
|
|
|
$commandTester = new CommandTester($command); |
37
|
|
|
$commandTester->execute([ |
38
|
|
|
'command' => $command->getName(), |
39
|
|
|
]); |
40
|
|
|
|
41
|
|
|
$output = $commandTester->getDisplay(); |
42
|
|
|
$this->assertSame('https://portiny.org/', $output); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|