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
|
|
|
|
13
|
|
|
public function testLoadConfiguration(): void |
14
|
|
|
{ |
15
|
|
|
$application = $this->container->getByType(Application::class); |
16
|
|
|
self::assertInstanceOf(Application::class, $application); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
public function testBeforeCompile(): void |
21
|
|
|
{ |
22
|
|
|
/** @var Application $application */ |
23
|
|
|
$application = $this->container->getByType(Application::class); |
24
|
|
|
|
25
|
|
|
self::assertFalse($application->isAutoExitEnabled()); |
26
|
|
|
self::assertTrue($application->areExceptionsCaught()); |
27
|
|
|
self::assertCount(3, $application->all()); |
28
|
|
|
self::assertTrue($application->has('print-request-url')); |
29
|
|
|
self::assertInstanceOf(PrintRequestUrlCommand::class, $application->get('print-request-url')); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function testExecution(): void |
34
|
|
|
{ |
35
|
|
|
/** @var Application $application */ |
36
|
|
|
$application = $this->container->getByType(Application::class); |
37
|
|
|
|
38
|
|
|
$command = $application->find('print-request-url'); |
39
|
|
|
$commandTester = new CommandTester($command); |
40
|
|
|
$commandTester->execute([ |
41
|
|
|
'command' => $command->getName(), |
42
|
|
|
]); |
43
|
|
|
|
44
|
|
|
$output = $commandTester->getDisplay(); |
45
|
|
|
self::assertSame('https://portiny.org/', $output); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
|