ConfigurationTest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 245
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 2
dl 0
loc 245
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfiguration() 0 4 1
B testValidConfiguration() 0 32 5
B validConfigurations() 0 109 1
A testInvalidConfiguration() 0 4 1
A invalidConfigurations() 0 75 1
1
<?php
2
3
namespace SLLH\StyleCIBridge\Tests\StyleCI;
4
5
use Matthias\SymfonyConfigTest\PhpUnit\AbstractConfigurationTestCase;
6
use SLLH\StyleCIBridge\StyleCI\Configuration;
7
8
class ConfigurationTest extends AbstractConfigurationTestCase
0 ignored issues
show
Deprecated Code introduced by
The class Matthias\SymfonyConfigTe...ctConfigurationTestCase has been deprecated with message: only use this class if you're still running php 5.3. Use
Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    protected function getConfiguration()
14
    {
15
        return new Configuration();
16
    }
17
18
    /**
19
     * @dataProvider validConfigurations
20
     *
21
     * @param array      $configuration
22
     * @param array|null $expectedProcessedConfiguration
23
     */
24
    public function testValidConfiguration(array $configuration, array $expectedProcessedConfiguration = null)
25
    {
26
        $this->assertConfigurationIsValid(array('styleci' => $configuration));
27
28
        // Set default expected configuration
29
        $expectedProcessedConfiguration = array_merge(array(
30
            'linting' => true,
31
            'enabled' => array(),
32
            'disabled' => array(),
33
            'risky' => true,
34
        ), $expectedProcessedConfiguration ?: $configuration);
35
36
        if (isset($configuration['finder'])) {
37
            $expectedFinderProcessedConfiguration = array_merge_recursive(array(
38
                'exclude' => array(),
39
                'name' => array(),
40
                'not_name' => array(),
41
                'contains' => array(),
42
                'not_contains' => array(),
43
                'path' => array(),
44
                'not_path' => array(),
45
                'depth' => array(),
46
            ), !empty($expectedProcessedConfiguration) && isset($expectedProcessedConfiguration['finder'])
47
                ? $expectedProcessedConfiguration['finder']
48
                : $configuration['finder']
49
            );
50
51
            $expectedProcessedConfiguration['finder'] = $expectedFinderProcessedConfiguration;
52
        }
53
54
        $this->assertProcessedConfigurationEquals(array('styleci' => $configuration), $expectedProcessedConfiguration);
55
    }
56
57
    public function validConfigurations()
58
    {
59
        return array(
60
            array(
61
                array(
62
                    'preset' => 'none',
63
                ),
64
            ),
65
            array(
66
                array(
67
                    'preset' => 'psr1',
68
                ),
69
            ),
70
            array(
71
                array(
72
                    'preset' => 'psr2',
73
                ),
74
            ),
75
            array(
76
                array(
77
                    'preset' => 'symfony',
78
                ),
79
            ),
80
            array(
81
                array(
82
                    'preset' => 'laravel',
83
                ),
84
            ),
85
            array(
86
                array(
87
                    'preset' => 'recommended',
88
                ),
89
            ),
90
            array(
91
                array(
92
                    'preset' => 'symfony',
93
                    'linting' => false,
94
                    'enabled' => array(
95
                        'return',
96
                        'phpdoc_params',
97
                    ),
98
                    'disabled' => array(
99
                        'short_array_syntax',
100
                    ),
101
                    'finder' => array(
102
                        'not_name' => array('*.dummy'),
103
                    ),
104
                ),
105
            ),
106
            array(
107
                array(
108
                    'preset' => 'symfony',
109
                    'finder' => array(
110
                        'not-name' => array('*.dummy'),
111
                    ),
112
                ),
113
                array(
114
                    'preset' => 'symfony',
115
                    'finder' => array(
116
                        'not_name' => array('*.dummy'),
117
                    ),
118
                ),
119
            ),
120
            array(
121
                array(
122
                    'preset' => 'symfony',
123
                    'enabled' => array(
124
                        'align_double_arrow',
125
                    ),
126
                    'disabled' => array(
127
                        'unalign_double_arrow',
128
                    ),
129
                ),
130
            ),
131
            // Scalar values
132
            array(
133
                array(
134
                    'preset' => 'symfony',
135
                    'enabled' => 'return',
136
                    'disabled' => 'long_array_syntax',
137
                    'finder' => array(
138
                        'exclude' => 'foo',
139
                        'name' => 'foo',
140
                        'not_name' => 'foo',
141
                        'contains' => 'foo',
142
                        'not_contains' => 'foo',
143
                        'path' => 'foo',
144
                        'not_path' => 'foo',
145
                        'depth' => 'foo',
146
                    ),
147
                ),
148
                array(
149
                    'preset' => 'symfony',
150
                    'enabled' => array('return'),
151
                    'disabled' => array('long_array_syntax'),
152
                    'finder' => array(
153
                        'exclude' => array('foo'),
154
                        'name' => array('foo'),
155
                        'not_name' => array('foo'),
156
                        'contains' => array('foo'),
157
                        'not_contains' => array('foo'),
158
                        'path' => array('foo'),
159
                        'not_path' => array('foo'),
160
                        'depth' => array('foo'),
161
                    ),
162
                ),
163
            ),
164
        );
165
    }
166
167
    /**
168
     * @dataProvider invalidConfigurations
169
     *
170
     * @param array $configuration
171
     */
172
    public function testInvalidConfiguration(array $configuration)
173
    {
174
        $this->assertConfigurationIsInvalid(array('styleci' => $configuration));
175
    }
176
177
    public function invalidConfigurations()
178
    {
179
        return array(
180
            array(
181
                array(),
182
            ),
183
            array(
184
                array(
185
                    'preset' => 'dummy',
186
                ),
187
            ),
188
            array(
189
                array(
190
                    'preset' => 'symfony',
191
                    'linting' => 42,
192
                ),
193
            ),
194
            array(
195
                array(
196
                    'preset' => 'symfony',
197
                    'linting' => false,
198
                    'enabled' => false,
199
                ),
200
            ),
201
            array(
202
                array(
203
                    'preset' => 'symfony',
204
                    'disabled' => false,
205
                ),
206
            ),
207
            array(
208
                array(
209
                    'preset' => 'symfony',
210
                    'enabled' => array(
211
                        'dummy',
212
                        'phpdoc_params',
213
                    ),
214
                ),
215
            ),
216
            array(
217
                array(
218
                    'preset' => 'symfony',
219
                    'disabled' => array(
220
                        'dummy',
221
                        'short_array_syntax',
222
                    ),
223
                ),
224
            ),
225
            array(
226
                array(
227
                    'preset' => 'symfony',
228
                    'finder' => array(
229
                        'not-existing-method' => array('*.dummy'),
230
                    ),
231
                ),
232
            ),
233
            array(
234
                array(
235
                    'preset' => 'symfony',
236
                    'enabled' => array(
237
                        'align_double_arrow',
238
                    ),
239
                ),
240
            ),
241
            array(
242
                array(
243
                    'preset' => 'psr1',
244
                    'enabled' => array(
245
                        'no_blank_lines_before_namespace',
246
                        'single_blank_line_before_namespace',
247
                    ),
248
                ),
249
            ),
250
        );
251
    }
252
}
253