1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace League\Tactician\Bundle\Tests\Integration; |
5
|
|
|
|
6
|
|
|
use League\Tactician\Bundle\Tests\Fake\FakeCommand; |
7
|
|
|
use League\Tactician\Bundle\Tests\Fake\OtherFakeCommand; |
8
|
|
|
use League\Tactician\Bundle\Tests\Fake\SomeHandler; |
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
10
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @runTestsInSeparateProcesses |
14
|
|
|
*/ |
15
|
|
|
final class DebugCommandTest extends IntegrationTest |
16
|
|
|
{ |
17
|
|
|
public function test_report() |
18
|
|
|
{ |
19
|
|
|
// GIVEN |
20
|
|
|
$this->givenConfig('tactician', <<<'EOF' |
21
|
|
|
commandbus: |
22
|
|
|
default: |
23
|
|
|
middleware: |
24
|
|
|
- tactician.middleware.command_handler |
25
|
|
|
EOF |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
$this->registerService('a.handler', SomeHandler::class, [['name' => 'tactician.handler', 'command' => FakeCommand::class]]); |
29
|
|
|
$this->registerService('b.handler', SomeHandler::class, [['name' => 'tactician.handler', 'command' => OtherFakeCommand::class]]); |
30
|
|
|
|
31
|
|
|
// WHEN |
32
|
|
|
$result = $this->runCommand()->getDisplay(); |
33
|
|
|
|
34
|
|
|
// THEN |
35
|
|
|
$expectation = <<<'EOF' |
36
|
|
|
|
37
|
|
|
Tactician routing |
38
|
|
|
================= |
39
|
|
|
|
40
|
|
|
Bus: default |
41
|
|
|
------------ |
42
|
|
|
|
43
|
|
|
----------------------------------------------------- ----------------- |
44
|
|
|
Command Handler Service |
45
|
|
|
----------------------------------------------------- ----------------- |
46
|
|
|
League\Tactician\Bundle\Tests\Fake\FakeCommand a.handler |
47
|
|
|
League\Tactician\Bundle\Tests\Fake\OtherFakeCommand b.handler |
48
|
|
|
----------------------------------------------------- ----------------- |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
EOF; |
52
|
|
|
|
53
|
|
|
$this->assertEquals( |
54
|
|
|
$expectation, |
55
|
|
|
$result |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return CommandTester |
61
|
|
|
*/ |
62
|
|
|
private function runCommand(): CommandTester |
63
|
|
|
{ |
64
|
|
|
$application = new Application(static::$kernel); |
65
|
|
|
|
66
|
|
|
$command = $application->find('debug:tactician'); |
67
|
|
|
$commandTester = new CommandTester($command); |
68
|
|
|
$commandTester->execute(array( |
69
|
|
|
'command' => $command->getName() |
70
|
|
|
)); |
71
|
|
|
return $commandTester; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|