|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace League\Tactician\Bundle\Tests\Integration; |
|
5
|
|
|
|
|
6
|
|
|
use League\Tactician\Bundle\DependencyInjection\Compiler\UnknownMiddlewareException; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @runTestsInSeparateProcesses |
|
10
|
|
|
*/ |
|
11
|
|
|
final class ValidatorTest extends IntegrationTest |
|
12
|
|
|
{ |
|
13
|
|
|
public function testCanBootKernelWhenOptionalComponentMiddlewareIsEnabled() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->givenConfig('framework', <<<'EOF' |
|
16
|
|
|
validation: |
|
17
|
|
|
enabled: true |
|
18
|
|
|
EOF |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
$this->givenConfig('tactician', <<<'EOF' |
|
22
|
|
|
commandbus: |
|
23
|
|
|
default: |
|
24
|
|
|
middleware: |
|
25
|
|
|
- tactician.middleware.validator |
|
26
|
|
|
EOF |
|
27
|
|
|
); |
|
28
|
|
|
static::$kernel->boot(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testCanNotBootKernelWhenOptionalComponentMiddlewareIsDisabled() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->expectException(UnknownMiddlewareException::class); |
|
34
|
|
|
|
|
35
|
|
|
$this->givenConfig('framework', <<<'EOF' |
|
36
|
|
|
validation: |
|
37
|
|
|
enabled: false |
|
38
|
|
|
EOF |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
$this->givenConfig('tactician', <<<'EOF' |
|
42
|
|
|
commandbus: |
|
43
|
|
|
default: |
|
44
|
|
|
middleware: |
|
45
|
|
|
- tactician.middleware.validator |
|
46
|
|
|
EOF |
|
47
|
|
|
); |
|
48
|
|
|
static::$kernel->boot(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testHandleCommandOnMiddlewareWithDependencies() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->givenConfig('framework', <<<'EOF' |
|
54
|
|
|
validation: |
|
55
|
|
|
enabled: true |
|
56
|
|
|
EOF |
|
57
|
|
|
); |
|
58
|
|
|
$this->givenConfig('tactician', <<<'EOF' |
|
59
|
|
|
commandbus: |
|
60
|
|
|
default: |
|
61
|
|
|
middleware: |
|
62
|
|
|
- tactician.middleware.validator |
|
63
|
|
|
- tactician.middleware.command_handler |
|
64
|
|
|
EOF |
|
65
|
|
|
); |
|
66
|
|
|
$this->registerService('tactician.test.handler', \League\Tactician\Bundle\Tests\EchoTextHandler::class, [ |
|
67
|
|
|
['name' => 'tactician.handler', 'command' => 'League\Tactician\Bundle\Tests\EchoText'], |
|
68
|
|
|
]); |
|
69
|
|
|
|
|
70
|
|
|
$this->expectOutputString('Hello world'); |
|
71
|
|
|
$this->handleCommand('default', \League\Tactician\Bundle\Tests\EchoText::class, ['Hello world']); |
|
72
|
|
|
} |
|
73
|
|
|
} |