Completed
Push — develop ( 7f6ad2...eb155e )
by Baptiste
02:38
created

LoggerListenerTest::testLog()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 0
cts 28
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 20
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Neo4jBundle\EventListener;
5
6
use Innmind\Neo4jBundle\EventListener\LoggerListener;
7
use Innmind\Neo4j\DBAL\{
8
    Events,
9
    Event\PreQueryEvent,
10
    Cypher
11
};
12
use Psr\Log\LoggerInterface;
13
14
class LoggerListenerTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testLog()
17
    {
18
        $called = false;
19
        $l = new LoggerListener(
20
           $m = $this->getMock(LoggerInterface::class)
21
        );
22
        $m
23
            ->method('info')
24
            ->will($this->returnCallback(function($message, $context) use (&$called) {
25
                $called = true;
26
                $this->assertSame('Cypher query about to be executed', $message);
27
                $this->assertSame('foo', $context['cypher']);
28
                $this->assertSame(
29
                    ['bar' => 'baz'],
30
                    $context['parameters']
31
                );
32
            }));
33
        $this->assertSame(
34
            null,
35
            $l->log(
36
                new PreQueryEvent(
37
                    (new Cypher('foo'))
38
                        ->withParameter('bar', 'baz')
39
                )
40
            )
41
        );
42
        $this->assertTrue($called);
43
    }
44
45
    public function testGetSubscribedEvents()
46
    {
47
        $this->assertSame(
48
            [Events::PRE_QUERY => 'log'],
49
            LoggerListener::getSubscribedEvents()
50
        );
51
    }
52
}
53