GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 37c564...56f4ad )
by Mario
01:32
created

ConfigurationTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 606
Duplicated Lines 97.03 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 3
dl 588
loc 606
rs 9.9821
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Netgen\Bundle\OpenGraphBundle\Tests\DependencyInjection;
4
5
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
6
use Netgen\Bundle\OpenGraphBundle\DependencyInjection\Configuration;
7
use PHPUnit\Framework\TestCase;
8
9
class ConfigurationTest extends TestCase
10
{
11
    use ConfigurationTestCaseTrait;
12
13
    public function testConfigurationValuesAreOkAndValid()
14
    {
15
        $this->assertConfigurationIsValid(
16
            array(
17
                'netgen_open_graph' => array(
18
                    'system' => array(
19
                        'default' => array(
20
                            'content_type_handlers' => array(
21
                                'content_type_one' => array(
22
                                    array(
23
                                        'handler' => 'literal/text',
24
                                        'tag' => 'og:type',
25
                                        'params' => array(
26
                                            'one',
27
                                            'two',
28
                                            'three',
29
                                        ),
30
                                    ),
31
                                    array(
32
                                        'handler' => 'field_type/ezstring',
33
                                        'tag' => 'og:title',
34
                                        'params' => array(
35
                                            'one',
36
                                            'two',
37
                                            'three',
38
                                        ),
39
                                    ),
40
                                ),
41
                                'content_type_two' => array(
42
                                    array(
43
                                        'handler' => 'field_type/ezstring',
44
                                        'tag' => 'og:title',
45
                                        'params' => array(
46
                                            'one',
47
                                            'two',
48
                                            'three',
49
                                        ),
50
                                    ),
51
                                ),
52
                            ),
53
                            'global_handlers' => array(
54
                                array(
55
                                    'handler' => 'literal/text',
56
                                    'tag' => 'og:type',
57
                                    'params' => array(
58
                                        'one',
59
                                        'two',
60
                                        'three',
61
                                    ),
62
                                ),
63
                                array(
64
                                    'handler' => 'field_type/ezstring',
65
                                    'tag' => 'og:title',
66
                                    'params' => array(
67
                                        'one',
68
                                        'two',
69
                                        'three',
70
                                    ),
71
                                ),
72
                            ),
73
                        ),
74
                    ),
75
                ),
76
            )
77
        );
78
    }
79
80
    public function testConfigurationWithoutRequiredHandlerInContentTypeHandlers()
81
    {
82
        $this->assertConfigurationIsInvalid(
83
            array(
84
                'netgen_open_graph' => array(
85
                    'system' => array(
86
                        'default' => array(
87
                            'content_type_handlers' => array(
88
                                'content_type_one' => array(
89
                                    array(
90
                                        'tag' => 'og:type',
91
                                        'params' => array(
92
                                            'one',
93
                                            'two',
94
                                            'three',
95
                                        ),
96
                                    ),
97
                                    array(
98
                                        'handler' => 'field_type/ezstring',
99
                                        'tag' => 'og:title',
100
                                        'params' => array(
101
                                            'one',
102
                                            'two',
103
                                            'three',
104
                                        ),
105
                                    ),
106
                                ),
107
                                'content_type_two' => array(
108
                                    array(
109
                                        'handler' => 'field_type/ezstring',
110
                                        'tag' => 'og:title',
111
                                        'params' => array(
112
                                            'one',
113
                                            'two',
114
                                            'three',
115
                                        ),
116
                                    ),
117
                                ),
118
                            ),
119
                            'global_handlers' => array(
120
                                array(
121
                                    'handler' => 'literal/text',
122
                                    'tag' => 'og:type',
123
                                    'params' => array(
124
                                        'one',
125
                                        'two',
126
                                        'three',
127
                                    ),
128
                                ),
129
                                array(
130
                                    'handler' => 'field_type/ezstring',
131
                                    'tag' => 'og:title',
132
                                    'params' => array(
133
                                        'one',
134
                                        'two',
135
                                        'three',
136
                                    ),
137
                                ),
138
                            ),
139
                        ),
140
                    ),
141
                ),
142
            ),
143
            'netgen_open_graph.system.default.content_type_handlers.content_type_one'
144
        );
145
    }
146
147
    public function testConfigurationWithHandlerEmptyInContentTypeHandlers()
148
    {
149
        $this->assertConfigurationIsInvalid(
150
            array(
151
                'netgen_open_graph' => array(
152
                    'system' => array(
153
                        'default' => array(
154
                            'content_type_handlers' => array(
155
                                'content_type_one' => array(
156
                                    array(
157
                                        'handler' => '',
158
                                        'tag' => 'og:type',
159
                                        'params' => array(
160
                                            'one',
161
                                            'two',
162
                                            'three',
163
                                        ),
164
                                    ),
165
                                    array(
166
                                        'handler' => 'field_type/ezstring',
167
                                        'tag' => 'og:title',
168
                                        'params' => array(
169
                                            'one',
170
                                            'two',
171
                                            'three',
172
                                        ),
173
                                    ),
174
                                ),
175
                                'content_type_two' => array(
176
                                    array(
177
                                        'handler' => 'field_type/ezstring',
178
                                        'tag' => 'og:title',
179
                                        'params' => array(
180
                                            'one',
181
                                            'two',
182
                                            'three',
183
                                        ),
184
                                    ),
185
                                ),
186
                            ),
187
                            'global_handlers' => array(
188
                                array(
189
                                    'handler' => 'literal/text',
190
                                    'tag' => 'og:type',
191
                                    'params' => array(
192
                                        'one',
193
                                        'two',
194
                                        'three',
195
                                    ),
196
                                ),
197
                                array(
198
                                    'handler' => 'field_type/ezstring',
199
                                    'tag' => 'og:title',
200
                                    'params' => array(
201
                                        'one',
202
                                        'two',
203
                                        'three',
204
                                    ),
205
                                ),
206
                            ),
207
                        ),
208
                    ),
209
                ),
210
            ),
211
            'netgen_open_graph.system.default.content_type_handlers.content_type_one'
212
        );
213
    }
214
215
    public function testConfigurationWithoutRequiredTagInContentTypeHandlers()
216
    {
217
        $this->assertConfigurationIsInvalid(
218
            array(
219
                'netgen_open_graph' => array(
220
                    'system' => array(
221
                        'default' => array(
222
                            'content_type_handlers' => array(
223
                                'content_type_one' => array(
224
                                    array(
225
                                        'handler' => 'field_type/ezstring',
226
                                        'params' => array(
227
                                            'one',
228
                                            'two',
229
                                            'three',
230
                                        ),
231
                                    ),
232
                                    array(
233
                                        'handler' => 'field_type/ezstring',
234
                                        'tag' => 'og:title',
235
                                    ),
236
                                ),
237
                                'content_type_two' => array(
238
                                    array(
239
                                        'handler' => 'field_type/ezstring',
240
                                        'tag' => 'og:title',
241
                                        'params' => array(
242
                                            'one',
243
                                            'two',
244
                                            'three',
245
                                        ),
246
                                    ),
247
                                ),
248
                            ),
249
                            'global_handlers' => array(
250
                                array(
251
                                    'handler' => 'literal/text',
252
                                    'tag' => 'og:type',
253
                                    'params' => array(
254
                                        'one',
255
                                        'two',
256
                                        'three',
257
                                    ),
258
                                ),
259
                                array(
260
                                    'handler' => 'field_type/ezstring',
261
                                    'tag' => 'og:title',
262
                                    'params' => array(
263
                                        'one',
264
                                        'two',
265
                                        'three',
266
                                    ),
267
                                ),
268
                            ),
269
                        ),
270
                    ),
271
                ),
272
            ),
273
            'netgen_open_graph.system.default.content_type_handlers.content_type_one'
274
        );
275
    }
276
277
    public function testConfigurationWithTagEmptyInContentTypeHandlers()
278
    {
279
        $this->assertConfigurationIsInvalid(
280
            array(
281
                'netgen_open_graph' => array(
282
                    'system' => array(
283
                        'default' => array(
284
                            'content_type_handlers' => array(
285
                                'content_type_one' => array(
286
                                    array(
287
                                        'handler' => 'field_type/ezstring',
288
                                        'tag' => '',
289
                                        'params' => array(
290
                                            'one',
291
                                            'two',
292
                                            'three',
293
                                        ),
294
                                    ),
295
                                    array(
296
                                        'handler' => 'field_type/ezstring',
297
                                        'tag' => 'og:title',
298
                                    ),
299
                                ),
300
                                'content_type_two' => array(
301
                                    array(
302
                                        'handler' => 'field_type/ezstring',
303
                                        'tag' => 'og:title',
304
                                        'params' => array(
305
                                            'one',
306
                                            'two',
307
                                            'three',
308
                                        ),
309
                                    ),
310
                                ),
311
                            ),
312
                            'global_handlers' => array(
313
                                array(
314
                                    'handler' => 'literal/text',
315
                                    'tag' => 'og:type',
316
                                    'params' => array(
317
                                        'one',
318
                                        'two',
319
                                        'three',
320
                                    ),
321
                                ),
322
                                array(
323
                                    'handler' => 'field_type/ezstring',
324
                                    'tag' => 'og:title',
325
                                    'params' => array(
326
                                        'one',
327
                                        'two',
328
                                        'three',
329
                                    ),
330
                                ),
331
                            ),
332
                        ),
333
                    ),
334
                ),
335
            ),
336
            'netgen_open_graph.system.default.content_type_handlers.content_type_one'
337
        );
338
    }
339
340
    public function testConfigurationWithoutRequiredHandlerInGlobalHandlers()
341
    {
342
        $this->assertConfigurationIsInvalid(
343
            array(
344
                'netgen_open_graph' => array(
345
                    'system' => array(
346
                        'default' => array(
347
                            'content_type_handlers' => array(
348
                                'content_type_one' => array(
349
                                    array(
350
                                        'handler' => 'field_type/ezstring',
351
                                        'tag' => 'og:type',
352
                                        'params' => array(
353
                                            'one',
354
                                            'two',
355
                                            'three',
356
                                        ),
357
                                    ),
358
                                    array(
359
                                        'handler' => 'field_type/ezstring',
360
                                        'tag' => 'og:title',
361
                                        'params' => array(
362
                                            'one',
363
                                            'two',
364
                                            'three',
365
                                        ),
366
                                    ),
367
                                ),
368
                                'content_type_two' => array(
369
                                    array(
370
                                        'handler' => 'field_type/ezstring',
371
                                        'tag' => 'og:title',
372
                                        'params' => array(
373
                                            'one',
374
                                            'two',
375
                                            'three',
376
                                        ),
377
                                    ),
378
                                ),
379
                            ),
380
                            'global_handlers' => array(
381
                                array(
382
                                    'tag' => 'og:type',
383
                                    'params' => array(
384
                                        'one',
385
                                        'two',
386
                                        'three',
387
                                    ),
388
                                ),
389
                                array(
390
                                    'handler' => 'field_type/ezstring',
391
                                    'tag' => 'og:title',
392
                                    'params' => array(
393
                                        'one',
394
                                        'two',
395
                                        'three',
396
                                    ),
397
                                ),
398
                            ),
399
                        ),
400
                    ),
401
                ),
402
            ),
403
            'netgen_open_graph.system.default.global_handlers'
404
        );
405
    }
406
407
    public function testConfigurationWithHandlerEmptyInGlobalHandlers()
408
    {
409
        $this->assertConfigurationIsInvalid(
410
            array(
411
                'netgen_open_graph' => array(
412
                    'system' => array(
413
                        'default' => array(
414
                            'content_type_handlers' => array(
415
                                'content_type_one' => array(
416
                                    array(
417
                                        'handler' => 'field_type/ezstring',
418
                                        'tag' => 'og:type',
419
                                        'params' => array(
420
                                            'one',
421
                                            'two',
422
                                            'three',
423
                                        ),
424
                                    ),
425
                                    array(
426
                                        'handler' => 'field_type/ezstring',
427
                                        'tag' => 'og:title',
428
                                        'params' => array(
429
                                            'one',
430
                                            'two',
431
                                            'three',
432
                                        ),
433
                                    ),
434
                                ),
435
                                'content_type_two' => array(
436
                                    array(
437
                                        'handler' => 'field_type/ezstring',
438
                                        'tag' => 'og:title',
439
                                        'params' => array(
440
                                            'one',
441
                                            'two',
442
                                            'three',
443
                                        ),
444
                                    ),
445
                                ),
446
                            ),
447
                            'global_handlers' => array(
448
                                array(
449
                                    'handler' => '',
450
                                    'tag' => 'og:type',
451
                                    'params' => array(
452
                                        'one',
453
                                        'two',
454
                                        'three',
455
                                    ),
456
                                ),
457
                                array(
458
                                    'handler' => 'field_type/ezstring',
459
                                    'tag' => 'og:title',
460
                                    'params' => array(
461
                                        'one',
462
                                        'two',
463
                                        'three',
464
                                    ),
465
                                ),
466
                            ),
467
                        ),
468
                    ),
469
                ),
470
            ),
471
            'netgen_open_graph.system.default.global_handlers'
472
        );
473
    }
474
475
    public function testConfigurationWithoutRequiredTagInGlobalHandlers()
476
    {
477
        $this->assertConfigurationIsInvalid(
478
            array(
479
                'netgen_open_graph' => array(
480
                    'system' => array(
481
                        'default' => array(
482
                            'content_type_handlers' => array(
483
                                'content_type_one' => array(
484
                                    array(
485
                                        'handler' => 'field_type/ezstring',
486
                                        'tag' => 'og:type',
487
                                        'params' => array(
488
                                            'one',
489
                                            'two',
490
                                            'three',
491
                                        ),
492
                                    ),
493
                                    array(
494
                                        'handler' => 'field_type/ezstring',
495
                                        'tag' => 'og:title',
496
                                        'params' => array(
497
                                            'one',
498
                                            'two',
499
                                            'three',
500
                                        ),
501
                                    ),
502
                                ),
503
                                'content_type_two' => array(
504
                                    array(
505
                                        'handler' => 'field_type/ezstring',
506
                                        'tag' => 'og:title',
507
                                        'params' => array(
508
                                            'one',
509
                                            'two',
510
                                            'three',
511
                                        ),
512
                                    ),
513
                                ),
514
                            ),
515
                            'global_handlers' => array(
516
                                array(
517
                                    'handler' => 'field_type/ezstring',
518
                                    'params' => array(
519
                                        'one',
520
                                        'two',
521
                                        'three',
522
                                    ),
523
                                ),
524
                                array(
525
                                    'handler' => 'field_type/ezstring',
526
                                    'tag' => 'og:title',
527
                                    'params' => array(
528
                                        'one',
529
                                        'two',
530
                                        'three',
531
                                    ),
532
                                ),
533
                            ),
534
                        ),
535
                    ),
536
                ),
537
            ),
538
            'netgen_open_graph.system.default.global_handlers'
539
        );
540
    }
541
542
    public function testConfigurationWithTagEmptyInGlobalHandlers()
543
    {
544
        $this->assertConfigurationIsInvalid(
545
            array(
546
                'netgen_open_graph' => array(
547
                    'system' => array(
548
                        'default' => array(
549
                            'content_type_handlers' => array(
550
                                'content_type_one' => array(
551
                                    array(
552
                                        'handler' => 'field_type/ezstring',
553
                                        'tag' => 'og:type',
554
                                        'params' => array(
555
                                            'one',
556
                                            'two',
557
                                            'three',
558
                                        ),
559
                                    ),
560
                                    array(
561
                                        'handler' => 'field_type/ezstring',
562
                                        'tag' => 'og:title',
563
                                        'params' => array(
564
                                            'one',
565
                                            'two',
566
                                            'three',
567
                                        ),
568
                                    ),
569
                                ),
570
                                'content_type_two' => array(
571
                                    array(
572
                                        'handler' => 'field_type/ezstring',
573
                                        'tag' => 'og:title',
574
                                        'params' => array(
575
                                            'one',
576
                                            'two',
577
                                            'three',
578
                                        ),
579
                                    ),
580
                                ),
581
                            ),
582
                            'global_handlers' => array(
583
                                array(
584
                                    'handler' => 'field_type/ezstring',
585
                                    'tag' => '',
586
                                    'params' => array(
587
                                        'one',
588
                                        'two',
589
                                        'three',
590
                                    ),
591
                                ),
592
                                array(
593
                                    'handler' => 'field_type/ezstring',
594
                                    'tag' => 'og:title',
595
                                    'params' => array(
596
                                        'one',
597
                                        'two',
598
                                        'three',
599
                                    ),
600
                                ),
601
                            ),
602
                        ),
603
                    ),
604
                ),
605
            ),
606
            'netgen_open_graph.system.default.global_handlers'
607
        );
608
    }
609
610
    protected function getConfiguration()
611
    {
612
        return new Configuration();
613
    }
614
}
615