Failed Conditions
Push — master ( ff1501...ac0e13 )
by Sergei
22s queued 17s
created

LoggingTest::testLogPrepareExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Tests\Functional;
6
7
use Doctrine\DBAL\Logging\SQLLogger;
8
use Doctrine\DBAL\Tests\FunctionalTestCase;
9
10
class LoggingTest extends FunctionalTestCase
11
{
12
    public function testLogExecuteQuery() : void
13
    {
14
        $sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
15
16
        $logMock = $this->createMock(SQLLogger::class);
17
        $logMock->expects($this->at(0))
18
                ->method('startQuery')
19
                ->with($this->equalTo($sql), $this->equalTo([]), $this->equalTo([]));
20
        $logMock->expects($this->at(1))
21
                ->method('stopQuery');
22
        $this->connection->getConfiguration()->setSQLLogger($logMock);
23
        $this->connection->executeQuery($sql, []);
24
    }
25
26
    public function testLogPrepareExecute() : void
27
    {
28
        $sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
29
30
        $logMock = $this->createMock(SQLLogger::class);
31
        $logMock->expects($this->once())
32
                ->method('startQuery')
33
                ->with($this->equalTo($sql), $this->equalTo([]));
34
        $logMock->expects($this->at(1))
35
                ->method('stopQuery');
36
        $this->connection->getConfiguration()->setSQLLogger($logMock);
37
38
        $stmt = $this->connection->prepare($sql);
39
        $stmt->execute();
40
    }
41
}
42