Failed Conditions
Push — master ( 070684...f9e00b )
by Sergei
64:19 queued 60:49
created

LoggerChainTest::testStopQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\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
        $chain = new LoggerChain([
36
            $this->createLogger($method, ...$args),
37
        ]);
38
39
        $chain->addLogger($this->createLogger($method, ...$args));
1 ignored issue
show
Deprecated Code introduced by
The function Doctrine\DBAL\Logging\LoggerChain::addLogger() has been deprecated: Inject list of loggers via constructor instead ( Ignorable by Annotation )

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

39
        /** @scrutinizer ignore-deprecated */ $chain->addLogger($this->createLogger($method, ...$args));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
40
41
        return $chain;
42
    }
43
44
    /**
45
     * @param mixed ...$args
46
     */
47
    private function createLogger(string $method, ...$args) : SQLLogger
48
    {
49
        $logger = $this->createMock(SQLLogger::class);
50
        $logger->expects($this->once())
51
            ->method($method)
52
            ->with(...$args);
53
54
        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...
55
    }
56
}
57