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

BundleInitializationTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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