FixerFactoryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testResolveFixerLevels() 0 14 2
A provideCreateData() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Symplify\MultiCodingStandard\Tests\PhpCsFixer\Factory;
6
7
use PhpCsFixer\Fixer\FixerInterface;
8
use PHPUnit\Framework\TestCase;
9
use Symplify\MultiCodingStandard\PhpCsFixer\Factory\FixerFactory;
10
11
final class FixerFactoryTest extends TestCase
12
{
13
    /**
14
     * @var FixerFactory
15
     */
16
    private $fixerFactory;
17
18
    protected function setUp()
19
    {
20
        $this->fixerFactory = new FixerFactory();
21
    }
22
23
    /**
24
     * @dataProvider provideCreateData
25
     */
26
    public function testResolveFixerLevels(
27
        array $fixerLevels,
28
        array $fixers,
29
        array $excludedFixers,
30
        int $expectedFixerCount
31
    ) {
32
        $fixers = $this->fixerFactory->createFromLevelsFixersAndExcludedFixers($fixerLevels, $fixers, $excludedFixers);
33
        $this->assertCount($expectedFixerCount, $fixers);
34
35
        if (count($fixers)) {
36
            $fixer = $fixers[0];
37
            $this->assertInstanceOf(FixerInterface::class, $fixer);
38
        }
39
    }
40
41
    public function provideCreateData() : array
42
    {
43
        return [
44
            [[], [], [], 0],
45
            [[], ['no_whitespace_before_comma_in_array'], [], 1],
46
            [['psr1'], [], [], 2],
47
            [['psr2'], [], [], 24],
48
            [['psr2'], [], ['visibility'],  24],
49
            [['psr1', 'psr2'], [], [], 26],
50
            [['psr1', 'psr2'], [], ['visibility'], 26],
51
        ];
52
    }
53
}
54