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; |
15
|
|
|
|
16
|
|
|
use Ekino\NewRelicBundle\EkinoNewRelicBundle; |
17
|
|
|
use Ekino\NewRelicBundle\NewRelic\AdaptiveInteractor; |
18
|
|
|
use Ekino\NewRelicBundle\NewRelic\BlackholeInteractor; |
19
|
|
|
use Ekino\NewRelicBundle\NewRelic\NewRelicInteractor; |
20
|
|
|
use Ekino\NewRelicBundle\NewRelic\NewRelicInteractorInterface; |
21
|
|
|
use Nyholm\BundleTest\BaseBundleTestCase; |
22
|
|
|
use Nyholm\BundleTest\CompilerPass\PublicServicePass; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Smoke test to see if the bundle can run. |
26
|
|
|
* |
27
|
|
|
* @author Tobias Nyholm <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
class BundleInitializationTest extends BaseBundleTestCase |
30
|
|
|
{ |
31
|
|
|
protected function setUp(): void |
32
|
|
|
{ |
33
|
|
|
parent::setUp(); |
34
|
|
|
|
35
|
|
|
// Make services public that have an idea that matches a regex |
36
|
|
|
$this->addCompilerPass(new PublicServicePass('|Ekino.*|i')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
protected function getBundleClass() |
40
|
|
|
{ |
41
|
|
|
return EkinoNewRelicBundle::class; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testInitBundle() |
45
|
|
|
{ |
46
|
|
|
// Boot the kernel. |
47
|
|
|
$this->bootKernel(); |
48
|
|
|
|
49
|
|
|
// Get the container |
50
|
|
|
$container = $this->getContainer(); |
51
|
|
|
|
52
|
|
|
$services = [ |
53
|
|
|
NewRelicInteractorInterface::class => AdaptiveInteractor::class, |
54
|
|
|
BlackholeInteractor::class, |
55
|
|
|
NewRelicInteractor::class, |
56
|
|
|
]; |
57
|
|
|
|
58
|
|
|
// Test if you services exists |
59
|
|
|
foreach ($services as $id => $class) { |
60
|
|
|
if (\is_int($id)) { |
61
|
|
|
$id = $class; |
62
|
|
|
} |
63
|
|
|
$this->assertTrue($container->has($id)); |
64
|
|
|
$service = $container->get($id); |
65
|
|
|
$this->assertInstanceOf($class, $service); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|