Completed
Push — v0.15-alpha ( 4f9a71...15bc85 )
by Valeriy
12:26
created

ConfigurationTest::testInvalidConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Ftrrtf\RollbarBundle\Tests\DependencyInjection;
4
5
use Ftrrtf\RollbarBundle\DependencyInjection\Configuration;
6
use Symfony\Component\Config\Definition\Processor;
7
8
class ConfigurationTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
12
     */
13
    public function testInvalidConfiguration()
14
    {
15
        $processor = new Processor();
16
        $processor->processConfiguration(new Configuration(), array());
17
    }
18
19
    /**
20
     * @dataProvider configurationDataProvider
21
     */
22
    public function testValidConfiguration($options, $configKey, $expectedConfig)
23
    {
24
        $processor = new Processor();
25
        $actualConfig = $processor->processConfiguration(
26
            new Configuration(),
27
            array($options)
28
        );
29
        static::assertEquals($expectedConfig, $actualConfig[$configKey]);
30
    }
31
32
    public function configurationDataProvider()
33
    {
34
        return array(
35
            'server curl transport configuration' => array(
36
                'options' => array(
37
                    'notifier' => array(
38
                        'server' => array(
39
                            'transport' => array(
40
                                'type' => 'curl',
41
                                'access_token' => 'token',
42
                            ),
43
                        ),
44
                    ),
45
                ),
46
                'check config key' => 'notifier',
47
                'expected config' => array(
48
                    'server' => array(
49
                        'batched' => false,
50
                        'batch_size' => '50',
51
                        'transport' => array(
52
                            'type' => 'curl',
53
                            'access_token' => 'token',
54
                        ),
55
                    ),
56
                ),
57
            ),
58
            'server agent transport configuration' => array(
59
                'options' => array(
60
                    'notifier' => array(
61
                        'server' => array(
62
                            'transport' => array(
63
                                'type' => 'agent',
64
                                'agent_log_location' => '/path/to/log',
65
                            ),
66
                        ),
67
                    ),
68
                ),
69
                'check config key' => 'notifier',
70
                'expected config' => array(
71
                    'server' => array(
72
                        'batched' => false,
73
                        'batch_size' => '50',
74
                        'transport' => array(
75
                            'type' => 'agent',
76
                            'agent_log_location' => '/path/to/log',
77
                        ),
78
                    ),
79
                ),
80
            ),
81
            'client js configuration' => array(
82
                'options' => array(
83
                    'notifier' => array(
84
                        'client' => array(
85
                            'access_token' => 'token',
86
                        ),
87
                    ),
88
                ),
89
                'check config key' => 'notifier',
90
                'expected config' => array(
91
                    'client' => array(
92
                        'access_token' => 'token',
93
                        'source_map_enabled' => false,
94
                        'code_version' => '',
95
                        'guess_uncaught_frames' => false,
96
                        'rollbarjs_version' => 'v1',
97
                        'allowed_js_hosts' => array(),
98
                    ),
99
                ),
100
            ),
101
            'environment configuration' => array(
102
                'options' => array(
103
                    'notifier' => array(),
104
                    'environment' => array(
105
                        'environment' => 'production',
106
                        'branch' => 'master',
107
                        'code_version' => '12345',
108
                    ),
109
                ),
110
                'check config key' => 'environment',
111
                'expected config' => array(
112
                    'environment' => 'production',
113
                    'branch' => 'master',
114
                    'root_dir' => '',
115
                    'code_version' => '12345',
116
                ),
117
            ),
118
        );
119
    }
120
}
121