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

LoggerListenerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 39
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testLog() 0 28 1
A testGetSubscribedEvents() 0 7 1
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