ConfigurationTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testEmptyConfiguration() 0 8 1
A process() 0 9 1
A testSetAValidBuilderVersion() 0 12 1
A testSetAnInvalidBuilderVersion() 0 10 1
1
<?php
2
3
namespace Tests\GBProd\ElasticaSpecificationBundle\DependencyInjection;
4
5
use GBProd\ElasticaSpecificationBundle\DependencyInjection\Configuration;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\Processor;
9
10
/**
11
 * Tests for Configuration
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class ConfigurationTest extends TestCase
16
{
17
    private $configuration;
18
19
    public function setUp()
20
    {
21
        $this->configuration = new Configuration();
22
    }
23
24
    public function testEmptyConfiguration()
25
    {
26
        $processed = $this->process([]);
27
28
        $this->assertEquals([
29
            'dsl_version' => 'Latest'
30
        ], $processed);
31
    }
32
33
    protected function process(array $config)
34
    {
35
        $processor = new Processor();
36
37
        return $processor->processConfiguration(
38
            $this->configuration,
39
            $config
40
        );
41
    }
42
43
    public function testSetAValidBuilderVersion()
44
    {
45
        $processed = $this->process([
46
            [
47
                'dsl_version' => 'Version240',
48
            ]
49
        ]);
50
51
        $this->assertEquals([
52
            'dsl_version' => 'Version240'
53
        ], $processed);
54
    }
55
56
    public function testSetAnInvalidBuilderVersion()
57
    {
58
        $this->expectException(\InvalidArgumentException::class);
59
60
        $this->process([
61
            [
62
                'dsl_version' => 'Fake',
63
            ]
64
        ]);
65
    }
66
}
67