ValidatorTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 63
rs 10
c 0
b 0
f 0

3 Methods

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