Completed
Push — master ( 3cf278...ee34b4 )
by Sullivan
02:21
created

ConfigBridgeTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 7
Bugs 1 Features 1
Metric Value
wmc 6
c 7
b 1
f 1
lcom 0
cbo 1
dl 0
loc 59
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B testDefaultConfig() 0 28 2
A testNonePreset() 0 10 2
A testNonePresetWithRules() 0 16 2
1
<?php
2
3
namespace SLLH\StyleCIBridge\Tests;
4
5
use SLLH\StyleCIBridge\ConfigBridge;
6
7
/**
8
 * @author Sullivan Senechal <[email protected]>
9
 */
10
class ConfigBridgeTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testDefaultConfig()
13
    {
14
        $config = ConfigBridge::create(__DIR__.'/Fixtures/configs/default');
15
16
        if (method_exists($config, 'getRules')) {
17
            $this->assertArraySubset(array(
18
                'align_double_arrow' => true,
19
                'long_array_syntax' => true,
20
                'linebreak_after_opening_tag' => true,
21
                'ordered_imports' => true,
22
                'psr0' => false,
23
                'unalign_double_arrow' => false,
24
                'unalign_equals' => false,
25
            ), $config->getRules());
26
        } else { // PHP-CS-Fixer 1.x BC
27
            $this->assertArraySubset(array(
28
                'align_double_arrow',
29
                'newline_after_open_tag',
30
                'ordered_use',
31
                'long_array_syntax',
32
                'linebreak_after_opening_tag',
33
                'ordered_imports',
34
                '-psr0',
35
                '-unalign_double_arrow',
36
                '-unalign_equals',
37
            ), $config->getFixers());
38
        }
39
    }
40
41
    public function testNonePreset()
42
    {
43
        $config = ConfigBridge::create(__DIR__.'/Fixtures/configs/none');
44
45
        if (method_exists($config, 'getRules')) {
46
            $this->assertSame(array(), $config->getRules());
47
        } else { // PHP-CS-Fixer 1.x BC
48
            $this->assertArraySubset(array(), $config->getFixers());
49
        }
50
    }
51
52
    public function testNonePresetWithRules()
53
    {
54
        $config = ConfigBridge::create(__DIR__.'/Fixtures/configs/none_with_rules');
55
56
        if (method_exists($config, 'getRules')) {
57
            $this->assertSame(array(
58
                'align_double_arrow' => true,
59
                'ordered_imports' => true,
60
            ), $config->getRules());
61
        } else { // PHP-CS-Fixer 1.x BC
62
            $this->assertArraySubset(array(
63
                'align_double_arrow',
64
                'ordered_use',
65
            ), $config->getFixers());
66
        }
67
    }
68
}
69