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

DbTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testWriteCompletedEventInDb() 0 18 1
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