1 | <?php |
||
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 |