LoggerChainTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testStopQuery() 0 4 1
A testStartQuery() 0 8 1
A createLogger() 0 8 1
A createChain() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Tests\Logging;
6
7
use Doctrine\DBAL\Logging\LoggerChain;
8
use Doctrine\DBAL\Logging\SQLLogger;
9
use Doctrine\DBAL\ParameterType;
10
use PHPUnit\Framework\TestCase;
11
12
class LoggerChainTest extends TestCase
13
{
14
    public function testStartQuery() : void
15
    {
16
        $sql    = 'SELECT ?';
17
        $params = [1];
18
        $types  = [ParameterType::INTEGER];
19
20
        $listener = $this->createChain('startQuery', $sql, $params, $types);
21
        $listener->startQuery($sql, $params, $types);
22
    }
23
24
    public function testStopQuery() : void
25
    {
26
        $listener = $this->createChain('stopQuery');
27
        $listener->stopQuery();
28
    }
29
30
    /**
31
     * @param mixed ...$args
32
     */
33
    private function createChain(string $method, ...$args) : LoggerChain
34
    {
35
        return new LoggerChain([
36
            $this->createLogger($method, ...$args),
37
            $this->createLogger($method, ...$args),
38
        ]);
39
    }
40
41
    /**
42
     * @param mixed ...$args
43
     */
44
    private function createLogger(string $method, ...$args) : SQLLogger
45
    {
46
        $logger = $this->createMock(SQLLogger::class);
47
        $logger->expects(self::once())
48
            ->method($method)
49
            ->with(...$args);
50
51
        return $logger;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $logger returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Doctrine\DBAL\Logging\SQLLogger.
Loading history...
52
    }
53
}
54