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\DocComment;
14
15
use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
16
use PhpCsFixer\FixerDefinition\FixerDefinition;
17
use PhpCsFixer\FixerDefinition\CodeSample;
18
use Addiks\MorePhpCsFixers\DocComment\CorrectOrderInVarDocCommentFixer;
19
20
/**
21
 * @internal
22
 */
23 View Code Duplication
final class CorrectOrderInVarDocCommentFixerTest 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
/** @var int $foo */
43
/** @var Foo $foo */
44
/** @var Foo\Bar $foo */
45
/** @var \Foo $foo */
46
/**
47
 * @var Foo $foo
48
 */
49
',
50
            ],
51
            [
52
                '<?php
53
/** @var string $foo */
54
/** @var int $foo */
55
/** @var Foo $foo */
56
/** @var Foo\Bar $foo */
57
/** @var \Foo $foo */
58
/**
59
 * @var Foo $foo
60
 */
61
',
62
                '<?php
63
/** @var $foo string */
64
/** @var $foo int */
65
/** @var $foo Foo */
66
/** @var $foo Foo\Bar */
67
/** @var $foo \Foo */
68
/**
69
 * @var $foo Foo
70
 */
71
',
72
            ],
73
            [
74
                '<?php
75
    /** @var string $foo */
76
    /** @var int $foo */
77
    /** @var Foo $foo */
78
    /** @var Foo\Bar $foo */
79
    /** @var \Foo $foo */
80
    /**
81
     * @var Foo $foo
82
     */
83
',
84
                '<?php
85
    /** @var $foo string */
86
    /** @var $foo int */
87
    /** @var $foo Foo */
88
    /** @var $foo Foo\Bar */
89
    /** @var $foo \Foo */
90
    /**
91
     * @var $foo Foo
92
     */
93
',
94
            ],
95
        ];
96
    }
97
98
    /**
99
     * @test
100
     */
101
    public function shouldHaveAFixerDefinition()
102
    {
103
        $this->assertEquals(
104
            new FixerDefinition(
105
                'Corrects the order of variable and typedeclaration in a @var doccomment.',
106
                [
107
                    new CodeSample(
108
                        '<?php
109
110
/** @var string $foo */
111
'
112
                    ),
113
                ]
114
            ),
115
            $this->createFixer()->getDefinition()
116
        );
117
    }
118
119
    protected function createFixer()
120
    {
121
        return new CorrectOrderInVarDocCommentFixer();
122
    }
123
124
}
125