Completed
Push — master ( a36c27...010ee5 )
by GBProd
02:47
created

Configuration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyConfiguration() 0 13 1
A process() 0 9 1
B testEmptyIndicesConfiguration() 0 25 1
B testIndexIsVariable() 0 38 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('clients')
24
                ->array($processed['clients'])
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
                    'clients' => [
46
                        'my_client' => [
47
                        ],                        
48
                        'my_client_2' => [
49
                        ],
50
                    ]
51
                ]
52
            ])
53
            ->if($processed = $this->process($config))
54
            ->then
55
                ->array($processed['clients'])
56
                    ->isNotEmpty()
57
                    ->hasKey('my_client')
58
                ->array($processed['clients']['my_client'])
59
                    ->hasKey('indices')
60
                ->array($processed['clients']['my_client']['indices'])
61
                    ->isEqualTo([])
62
        ;
63
    }
64
 
65
 
66
    public function testIndexIsVariable()
67
    {
68
        $this
69
            ->given($this->newTestedInstance)
70
            ->and($config = [
71
                [
72
                    'clients' => [
73
                        'my_client' => [
74
                            'indices' => [
75
                                'index_1' => [
76
                                    'foo' => [
77
                                        'bar',
78
                                    ],
79
                                ],
80
                                'index_2' => [
81
                                    'fizz' => [
82
                                    ],
83
                                    'mapping' => [
84
                                    ],
85
                                ],
86
                            ]
87
                        ],
88
                    ]
89
                ]
90
            ])
91
            ->if($processed = $this->process($config))
92
            ->then
93
                ->array($processed['clients']['my_client']['indices'])
94
                    ->hasKey('index_1')
95
                ->array($processed['clients']['my_client']['indices']['index_1'])
96
                    ->isEqualTo([
97
                            'foo' => [
98
                                'bar',
99
                            ],
100
                        ]
101
                    )
102
        ;
103
    }
104
}