BlankLineBeforeDocCommentFixerTest::createFixer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Addiks\MorePhpCsFixers\Tests\Unit\Whitespace;
14
15
use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
16
use Addiks\MorePhpCsFixers\Whitespace\BlankLineBeforeDocCommentFixer;
17
use PhpCsFixer\FixerDefinition\FixerDefinition;
18
use PhpCsFixer\FixerDefinition\CodeSample;
19
20
/**
21
 * @internal
22
 */
23 View Code Duplication
final class BlankLineBeforeDocCommentFixerTest extends AbstractFixerTestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    /**
26
     * @param string      $expected
27
     * @param null|string $input
28
     *
29
     * @dataProvider provideFixCases
30
     */
31
    public function testFix($expected, $input = null)
32
    {
33
        $this->doTest($expected, $input);
34
    }
35
36
    public function provideFixCases()
37
    {
38
        return [
39
            [
40
                '<?php
41
/** @var string $foo */
42
$foo = "Lorem ipsum";
43
44
/** @var string $bar */
45
$bar = "dolor sit";
46
47
/** @var string $baz */
48
$baz = "amet";
49
',
50
            ],
51
            [
52
                '<?php
53
/** @var string $foo */
54
$foo = "Lorem ipsum";
55
56
/** @var string $bar */
57
$bar = "dolor sit";
58
59
/** @var string $baz */
60
$baz = "amet";
61
',
62
                '<?php
63
/** @var string $foo */
64
$foo = "Lorem ipsum";
65
/** @var string $bar */
66
$bar = "dolor sit";
67
/** @var string $baz */
68
$baz = "amet";
69
',
70
            ],
71
            [
72
                '<?php
73
    /** @var string $foo */
74
    $foo = "Lorem ipsum";
75
76
    /** @var string $bar */
77
    $bar = "dolor sit";
78
79
    /** @var string $baz */
80
    $baz = "amet";
81
    ',
82
                '<?php
83
    /** @var string $foo */
84
    $foo = "Lorem ipsum";
85
    /** @var string $bar */
86
    $bar = "dolor sit";
87
    /** @var string $baz */
88
    $baz = "amet";
89
    ',
90
            ],
91
            [
92
                '<?php
93
function foo() {
94
    /** @var string $foo */
95
    $foo = "Lorem ipsum";
96
97
    /** @var string $bar */
98
    $bar = "dolor sit";
99
}
100
',
101
                '<?php
102
function foo() {
103
    /** @var string $foo */
104
    $foo = "Lorem ipsum";
105
    /** @var string $bar */
106
    $bar = "dolor sit";
107
}
108
',
109
            ],
110
        ];
111
    }
112
113
    /**
114
     * @test
115
     */
116
    public function shouldHaveAFixerDefinition()
117
    {
118
        $this->assertEquals(
119
            new FixerDefinition(
120
                'An empty line feed must precede any doc-comment.',
121
                [
122
                    new CodeSample(
123
                        '<?php
124
125
/** @var string $foo */
126
$foo = "Lorem ipsum";
127
128
/** @var string $bar */
129
$bar = "dolor sit amet";
130
'
131
                    ),
132
                ]
133
            ),
134
            $this->createFixer()->getDefinition()
135
        );
136
    }
137
138
    /**
139
     * @test
140
     */
141
    public function shouldHaveTheRightPriority()
142
    {
143
        $this->assertEquals(-26, $this->createFixer()->getPriority());
144
    }
145
146
    protected function createFixer()
147
    {
148
        return new BlankLineBeforeDocCommentFixer();
149
    }
150
151
}
152