Completed
Push — master ( d72a06...ba0ad0 )
by GBProd
04:38
created

Configuration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 85
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyConfiguration() 0 13 1
A process() 0 9 1
A testEmptyIndicesConfiguration() 0 22 1
B testIndexIsVariable() 0 34 1
1
<?php
2
3
namespace GBProd\Tests\Units\ElasticsearchExtraBundle\DependencyInjection;
4
5
use atoum;
6
use Symfony\Component\Config\Definition\Processor;
7
8
/**
9
 * Configuration
10
 *
11
 * @author gbprod <[email protected]>
12
 */
13
class Configuration extends atoum
14
{
15
    public function testEmptyConfiguration()
16
    {
17
        $this
18
            ->given($this->newTestedInstance)
19
            ->and($config = [])
20
            ->if($processed = $this->process($config))
21
            ->then
22
                ->array($processed)
23
                    ->hasKey('indices')
24
                ->array($processed['indices'])
25
                    ->isEmpty()
26
        ;
27
    }
28
29
    protected function process($config)
30
    {
31
        $processor = new Processor();
32
33
        return $processor->processConfiguration(
34
            $this->testedInstance,
35
            $config
36
        );
37
    }
38
39
    public function testEmptyIndicesConfiguration()
40
    {
41
        $this
42
            ->given($this->newTestedInstance)
43
            ->and($config = [
44
                [
45
                    'indices' => [
46
                        'my_index' => [
47
                        ],
48
                        'my_index_2' => [
49
                        ],
50
                    ]
51
                ]
52
            ])
53
            ->if($processed = $this->process($config))
54
            ->then
55
                ->array($processed['indices'])
56
                    ->isNotEmpty()
57
                    ->hasKey('my_index')
58
                    ->hasKey('my_index_2')
59
        ;
60
    }
61
62
63
    public function testIndexIsVariable()
64
    {
65
        $this
66
            ->given($this->newTestedInstance)
67
            ->and($config = [
68
                [
69
                    'indices' => [
70
                        'index_1' => [
71
                            'foo' => [
72
                                'bar',
73
                            ],
74
                        ],
75
                        'index_2' => [
76
                            'fizz' => [
77
                            ],
78
                            'mapping' => [
79
                            ],
80
                        ],
81
                    ]
82
                ]
83
            ])
84
            ->if($processed = $this->process($config))
85
            ->then
86
                ->array($processed['indices'])
87
                    ->hasKey('index_1')
88
                ->array($processed['indices']['index_1'])
89
                    ->isEqualTo([
90
                            'foo' => [
91
                                'bar',
92
                            ],
93
                        ]
94
                    )
95
        ;
96
    }
97
}
98