testLoggerMiddlewareLogsOnlyLoggableCommands()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 0
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