AbstractExtensionTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 61
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
loadConfiguration() 0 1 ?
A getContainer() 0 11 2
A testWithoutConfiguration() 0 6 1
A testFullConfiguration() 0 6 1
A testMediumConfiguration() 0 6 1
A testMinimumConfiguration() 0 6 1
A testStorageProvidersAreProperlyRegisteredByTheirName() 0 16 2
1
<?php
2
3
namespace Mathielen\ImportEngineBundle\Tests\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
7
abstract class AbstractExtensionTest extends AbstractTest
8
{
9
    abstract protected function loadConfiguration(ContainerBuilder $container, $resource);
10
11
    private function getContainer($resource = null)
12
    {
13
        if ($resource) {
14
            $this->loadConfiguration($this->container, $resource);
15
        }
16
17
        $this->container->loadFromExtension($this->extension->getAlias());
18
        $this->container->compile();
19
20
        return $this->container;
21
    }
22
23
    public function testWithoutConfiguration()
24
    {
25
        $container = $this->getContainer();
26
        $this->assertFalse($container->has('mathielen_importengine.import.storagelocator'));
27
        $this->assertFalse($container->has('mathielen_importengine.import.builder'));
28
    }
29
30
    public function testFullConfiguration()
31
    {
32
        $container = $this->getContainer('full');
33
        $this->assertTrue($container->has('mathielen_importengine.import.storagelocator'));
34
        $this->assertTrue($container->has('mathielen_importengine.import.builder'));
35
    }
36
37
    public function testMediumConfiguration()
38
    {
39
        $container = $this->getContainer('medium');
40
        $this->assertTrue($container->has('mathielen_importengine.import.storagelocator'));
41
        $this->assertTrue($container->has('mathielen_importengine.import.builder'));
42
    }
43
44
    public function testMinimumConfiguration()
45
    {
46
        $container = $this->getContainer('minimum');
47
        $this->assertTrue($container->has('mathielen_importengine.import.storagelocator'));
48
        $this->assertTrue($container->has('mathielen_importengine.import.builder'));
49
    }
50
51
    public function testStorageProvidersAreProperlyRegisteredByTheirName()
52
    {
53
        $container = $this->getContainer('full');
54
55
        $storageLocatorDef = $container->findDefinition('mathielen_importengine.import.storagelocator');
56
        $methodCalls = $storageLocatorDef->getMethodCalls();
57
58
        $registeredStorageProviderIds = [];
59
        foreach ($methodCalls as $methodCall) {
60
            $arguments = $methodCall[1];
61
62
            $registeredStorageProviderIds[] = $arguments[0];
63
        }
64
65
        $this->assertEquals(['upload', 'localdir', 'localfile', 'doctrine', 'services'], $registeredStorageProviderIds);
66
    }
67
}
68