Passed
Push — master ( c2b6eb...8c3bb9 )
by Sébastien
09:25
created

ConfigurationTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 43
c 1
b 0
f 0
dl 0
loc 73
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_valid_config() 0 7 1
A configDataProvider() 0 56 1
1
<?php
2
3
namespace Bdf\QueueBundle\Tests\DependencyInjection;
4
5
use Bdf\QueueBundle\DependencyInjection\Configuration;
6
use PHPUnit\Framework\TestCase;
7
8
class ConfigurationTest extends TestCase
9
{
10
    public function configDataProvider(): array
11
    {
12
        return [
13
            [
14
                'empty',
15
                [
16
                ],
17
                [
18
                    'default_connection' => null,
19
                    'default_serializer' => 'bdf',
20
                    'failer' => 'memory:',
21
                    'connections' => [],
22
                    'destinations' => [],
23
                ],
24
            ],
25
            [
26
                'consumer options',
27
                [
28
                    'destinations' => [
29
                        'foo' => [
30
                            'consumer' => [
31
                                'no_reset' => true,
32
                                'retry' => 2,
33
                                'max' => 3,
34
                                'limit' => 4,
35
                                'memory' => 128,
36
                                'save' => true,
37
                                'no_failure' => true,
38
                                'stop_when_empty' => true,
39
                                'auto_handle' => false,
40
                            ]
41
                        ]
42
                    ],
43
                ],
44
                [
45
                    'destinations' => [
46
                        'foo' => [
47
                            'consumer' => [
48
                                'no_reset' => true,
49
                                'retry' => 2,
50
                                'max' => 3,
51
                                'limit' => 4,
52
                                'memory' => 128,
53
                                'save' => true,
54
                                'no_failure' => true,
55
                                'stop_when_empty' => true,
56
                                'auto_handle' => false,
57
                                'handler' => null,
58
                                'middlewares' => [],
59
                            ]
60
                        ]
61
                    ],
62
                    'default_connection' => null,
63
                    'default_serializer' => 'bdf',
64
                    'failer' => 'memory:',
65
                    'connections' => [],
66
                ],
67
            ],
68
        ];
69
    }
70
71
    /**
72
     * @dataProvider configDataProvider
73
     */
74
    public function test_valid_config(string $description, array $config, array $expected)
75
    {
76
        $cfg = new Configuration();
77
        $tree = $cfg->getConfigTreeBuilder()->buildTree();
78
        $result = $tree->finalize($tree->normalize($config));
79
80
        self::assertSame($expected, $result, $description);
81
    }
82
}
83