ContainerTestCase   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A givenContainerWithFixtureFiles() 0 14 2
A buildContainer() 0 9 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace TomCizek\AsynchronousRouter\Tests\DependencyInjection;
6
7
use PHPUnit\Framework\TestCase;
8
use Prooph\Bundle\ServiceBus\DependencyInjection\ProophServiceBusExtension;
9
use Symfony\Component\Config\FileLocator;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
12
use TomCizek\AsynchronousRouter\DependencyInjection\ProophAsynchronousRouterExtension;
13
14
abstract class ContainerTestCase extends TestCase
15
{
16
    /** @var ContainerBuilder */
17
    protected $containerBuilder;
18
19
    protected function givenContainerWithFixtureFiles(
20
        array $fixtureFiles = []
21
    ) {
22
        $container = $this->buildContainer()
23
            ->withExtensions(
24
                new ProophAsynchronousRouterExtension(),
25
                new ProophServiceBusExtension()
26
            );
27
        foreach ($fixtureFiles as $fixtureFile) {
28
            $container->withConfigFiles($fixtureFile);
29
        }
30
31
        $this->containerBuilder = $container->compile();
32
    }
33
34
    private function buildContainer(): TestContainerBuilder
35
    {
36
        return TestContainerBuilder::buildContainer(
37
            function (ContainerBuilder $container) {
38
                return new YamlFileLoader($container, new FileLocator(__DIR__ . '/Fixture/config/yml'));
39
            },
40
            'yml'
41
        );
42
    }
43
}
44