Passed
Push — master ( da9ebc...eab3b6 )
by Tobias
02:14
created

MonologHandlerPassTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testProcessChannel() 0 10 1
A registerCompilerPass() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Ekino New Relic bundle.
7
 *
8
 * (c) Ekino - Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\NewRelicBundle\Tests\DependencyInjection\Compiler;
15
16
use Ekino\NewRelicBundle\DependencyInjection\Compiler\MonologHandlerPass;
17
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Reference;
20
21
class MonologHandlerPassTest extends AbstractCompilerPassTestCase
22
{
23
    protected function registerCompilerPass(ContainerBuilder $container)
24
    {
25
        $container->addCompilerPass(new MonologHandlerPass());
26
    }
27
28
    public function testProcessChannel()
29
    {
30
        $this->container->setParameter('ekino.new_relic.monolog.channels', ['app', 'foo']);
31
        $this->registerService('monolog.logger', \Monolog\Logger::class);
32
        $this->registerService('monolog.logger.foo', \Monolog\Logger::class);
33
34
        $this->compile();
35
36
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('monolog.logger', 'pushHandler', [new Reference('ekino.new_relic.logs_handler')]);
37
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('monolog.logger.foo', 'pushHandler', [new Reference('ekino.new_relic.logs_handler')]);
38
    }
39
}
40