MiddlewareTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testLoggerMiddlewareLogsOnlyLoggableCommands() 0 11 1
A setUp() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\PHPCommandBus\Tests\Integration;
6
7
use RemotelyLiving\PHPCommandBus\Interfaces;
8
use RemotelyLiving\PHPCommandBus\Tests\Stubs;
9
10
class MiddlewareTest extends AbstractTestCase
11
{
12
    private Interfaces\CommandBus $commandBus;
13
14
    protected function setUp(): void
15
    {
16
        $this->commandBus = $this->createConfiguredCommandBus();
17
    }
18
19
    public function testLoggerMiddlewareLogsOnlyLoggableCommands(): void
20
    {
21
        $this->commandBus->handle(new Stubs\Commands\PublishDraft());
22
        $this->commandBus->handle(new Stubs\Commands\ReserveRoom());
23
        $this->assertEquals([
24
            'level' => 'info',
25
            'message' => 'Trying to publish a draft',
26
            'context' => ['draftData' => (new Stubs\Commands\PublishDraft())->getDraftData()]
27
        ], $this->testLogger->records[0]);
28
29
        $this->assertCount(1, $this->testLogger->records);
30
    }
31
}
32