Passed
Push — master ( 89f24e...8c4dad )
by Sylvain
08:05
created

DbTest::testWriteCompletedEventInDb()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.8333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix\Log\Writer;
6
7
use Ecodev\Felix\Log\EventCompleter;
8
use Ecodev\Felix\Log\Writer\Db;
9
use Ecodev\Felix\Repository\LogRepository;
10
use PHPUnit\Framework\TestCase;
11
12
class DbTest extends TestCase
13
{
14
    public function testWriteCompletedEventInDb(): void
15
    {
16
        $event = ['message' => 'original'];
17
        $completedEvent = ['message' => 'completed'];
18
19
        $logRepository = self::createMock(LogRepository::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::createMock() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        /** @scrutinizer ignore-call */ 
20
        $logRepository = self::createMock(LogRepository::class);
Loading history...
20
        $logRepository->expects(self::once())
21
            ->method('log')
22
            ->with($completedEvent);
23
24
        $eventCompleter = self::createMock(EventCompleter::class);
25
        $eventCompleter->expects(self::once())
26
            ->method('process')
27
            ->with($event)
28
            ->willReturn($completedEvent);
29
30
        $writer = new Db($logRepository, $eventCompleter);
31
        $writer->write($event);
32
    }
33
}
34