Passed
Pull Request — master (#155)
by Tobias
02:40
created

EkinoNewRelicExtensionTest::testMonolog()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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\Bundle\NewRelicBundle\Tests\DependencyInjection;
15
16
use Ekino\Bundle\NewRelicBundle\DependencyInjection\EkinoNewRelicExtension;
17
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
18
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\ContainerHasParameterConstraint;
19
use PHPUnit\Framework\Constraint\LogicalNot;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\Constraint\LogicalNot was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
class EkinoNewRelicExtensionTest extends AbstractExtensionTestCase
22
{
23
    protected function getContainerExtensions()
24
    {
25
        return [new EkinoNewRelicExtension()];
26
    }
27
28
    protected function setUp()
29
    {
30
        parent::setUp();
31
32
        $this->setParameter('kernel.bundles', []);
33
    }
34
35
    public function testDefaultConfiguration()
36
    {
37
        $this->load();
38
39
        $this->assertContainerBuilderHasService('ekino.new_relic.twig.new_relic_extension');
40
        $this->assertContainerBuilderHasService('ekino.new_relic.command_listener');
41
        $this->assertContainerBuilderHasService('ekino.new_relic.exception_listener');
42
    }
43
44
    public function testAlternativeConfiguration()
45
    {
46
        $this->load([
47
            'exceptions' => false,
48
            'commands' => false,
49
            'twig' => false,
50
        ]);
51
52
        $this->assertContainerBuilderNotHasService('ekino.new_relic.twig.new_relic_extension');
53
        $this->assertContainerBuilderNotHasService('ekino.new_relic.command_listener');
54
        $this->assertContainerBuilderNotHasService('ekino.new_relic.exception_listener');
55
    }
56
57
    public function testDeprecation()
58
    {
59
        $this->load();
60
61
        $this->assertContainerBuilderHasService('ekino.new_relic.deprecation_listener');
62
    }
63
64
    public function testMonolog()
65
    {
66
        $this->load(['monolog' => true]);
67
68
        $this->assertContainerBuilderHasParameter('ekino.new_relic.monolog.channels');
69
        $this->assertContainerBuilderHasService('ekino.new_relic.logs_handler');
70
        $this->assertContainerBuilderHasServiceDefinitionWithArgument('ekino.new_relic.logs_handler', 0, 400);
71
    }
72
73
    public function testMonologDisabled()
74
    {
75
        $this->load(['monolog' => false]);
76
77
        self::assertThat(
78
            $this->container,
79
            new LogicalNot(new ContainerHasParameterConstraint('ekino.new_relic.monolog.channels', null, false))
80
        );
81
    }
82
83
    public function testConfigDisabled()
84
    {
85
        $this->load([
86
            'enabled' => false,
87
        ]);
88
89
        $this->assertContainerBuilderHasAlias('ekino.new_relic.interactor', 'ekino.new_relic.interactor.blackhole');
90
    }
91
92
    public function testConfigDisabledWithInteractor()
93
    {
94
        $this->load([
95
            'enabled' => false,
96
            'interactor' => 'ekino.new_relic.interactor.adaptive',
97
        ]);
98
99
        $this->assertContainerBuilderHasAlias('ekino.new_relic.interactor', 'ekino.new_relic.interactor.blackhole');
100
    }
101
102
    public function testConfigEnabledWithInteractor()
103
    {
104
        $this->load([
105
            'enabled' => true,
106
            'interactor' => 'ekino.new_relic.interactor.adaptive',
107
        ]);
108
109
        $this->assertContainerBuilderHasAlias('ekino.new_relic.interactor', 'ekino.new_relic.interactor.adaptive');
110
    }
111
}
112