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; |
15
|
|
|
|
16
|
|
|
use Ekino\NewRelicBundle\DependencyInjection\EkinoNewRelicExtension; |
17
|
|
|
use Ekino\NewRelicBundle\Listener\CommandListener; |
18
|
|
|
use Ekino\NewRelicBundle\Listener\DeprecationListener; |
19
|
|
|
use Ekino\NewRelicBundle\Listener\ExceptionListener; |
20
|
|
|
use Ekino\NewRelicBundle\NewRelic\BlackholeInteractor; |
21
|
|
|
use Ekino\NewRelicBundle\Twig\NewRelicExtension; |
22
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
23
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\ContainerHasParameterConstraint; |
24
|
|
|
use PHPUnit\Framework\Constraint\LogicalNot; |
|
|
|
|
25
|
|
|
|
26
|
|
|
class EkinoNewRelicExtensionTest extends AbstractExtensionTestCase |
27
|
|
|
{ |
28
|
|
|
protected function getContainerExtensions() |
29
|
|
|
{ |
30
|
|
|
return [new EkinoNewRelicExtension()]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
protected function setUp() |
34
|
|
|
{ |
35
|
|
|
parent::setUp(); |
36
|
|
|
|
37
|
|
|
$this->setParameter('kernel.bundles', []); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testDefaultConfiguration() |
41
|
|
|
{ |
42
|
|
|
$this->load(); |
43
|
|
|
|
44
|
|
|
$this->assertContainerBuilderHasService(NewRelicExtension::class); |
45
|
|
|
$this->assertContainerBuilderHasService(CommandListener::class); |
46
|
|
|
$this->assertContainerBuilderHasService(ExceptionListener::class); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testAlternativeConfiguration() |
50
|
|
|
{ |
51
|
|
|
$this->load([ |
52
|
|
|
'exceptions' => false, |
53
|
|
|
'commands' => false, |
54
|
|
|
'twig' => false, |
55
|
|
|
]); |
56
|
|
|
|
57
|
|
|
$this->assertContainerBuilderNotHasService(NewRelicExtension::class); |
58
|
|
|
$this->assertContainerBuilderNotHasService(CommandListener::class); |
59
|
|
|
$this->assertContainerBuilderNotHasService(ExceptionListener::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testDeprecation() |
63
|
|
|
{ |
64
|
|
|
$this->load(); |
65
|
|
|
|
66
|
|
|
$this->assertContainerBuilderHasService(DeprecationListener::class); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testMonolog() |
70
|
|
|
{ |
71
|
|
|
$this->load(['monolog' => true]); |
72
|
|
|
|
73
|
|
|
$this->assertContainerBuilderHasParameter('ekino.new_relic.monolog.channels'); |
74
|
|
|
$this->assertContainerBuilderHasService('ekino.new_relic.logs_handler'); |
75
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithArgument('ekino.new_relic.logs_handler', 0, 400); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testMonologDisabled() |
79
|
|
|
{ |
80
|
|
|
$this->load(['monolog' => false]); |
81
|
|
|
|
82
|
|
|
self::assertThat( |
83
|
|
|
$this->container, |
84
|
|
|
new LogicalNot(new ContainerHasParameterConstraint('ekino.new_relic.monolog.channels', null, false)) |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function testConfigDisabled() |
89
|
|
|
{ |
90
|
|
|
$this->load([ |
91
|
|
|
'enabled' => false, |
92
|
|
|
]); |
93
|
|
|
|
94
|
|
|
$this->assertContainerBuilderHasAlias('ekino.new_relic.interactor', BlackholeInteractor::class); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function testConfigDisabledWithInteractor() |
98
|
|
|
{ |
99
|
|
|
$this->load([ |
100
|
|
|
'enabled' => false, |
101
|
|
|
'interactor' => 'ekino.new_relic.interactor.adaptive', |
102
|
|
|
]); |
103
|
|
|
|
104
|
|
|
$this->assertContainerBuilderHasAlias('ekino.new_relic.interactor', BlackholeInteractor::class); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function testConfigEnabledWithInteractor() |
108
|
|
|
{ |
109
|
|
|
$this->load([ |
110
|
|
|
'enabled' => true, |
111
|
|
|
'interactor' => 'ekino.new_relic.interactor.adaptive', |
112
|
|
|
]); |
113
|
|
|
|
114
|
|
|
$this->assertContainerBuilderHasAlias('ekino.new_relic.interactor', 'ekino.new_relic.interactor.adaptive'); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths