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

Configuration::testEmptyIndicesConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 13
nc 1
nop 0
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