Completed
Pull Request — master (#187)
by Juliette
03:59
created

EmptyNonVariableSniffTest::dataNoViolation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 14
loc 14
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 * Empty with non variable sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Empty with non variable sniff test file
11
 *
12
 * @uses    BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author  Juliette Reinders Folmer <[email protected]>
15
 */
16
class EmptyNonVariableSniffTest extends BaseSniffTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    const TEST_FILE = 'sniff-examples/empty_non_variable.php';
19
20
    /**
21
     * testEmptyNonVariable
22
     *
23
     * @group emptyNonVariable
24
     *
25
     * @dataProvider dataEmptyNonVariable
26
     *
27
     * @param int $line The line number.
28
     *
29
     * @return void
30
     */
31 View Code Duplication
    public function testEmptyNonVariable($line)
0 ignored issues
show
Duplication introduced by
This method 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...
32
    {
33
        $file = $this->sniffFile(self::TEST_FILE, '5.4');
34
        $this->assertError($file, $line, 'Only variables can be passed to empty() prior to PHP 5.5.');
35
36
        $file = $this->sniffFile(self::TEST_FILE, '5.5');
37
        $this->assertNoViolation($file, $line);
38
    }
39
40
    /**
41
     * Data provider.
42
     *
43
     * @see testEmptyNonVariable()
44
     *
45
     * @return array
46
     */
47
    public function dataEmptyNonVariable()
48
    {
49
        return array(
50
            array(15),
51
            array(16),
52
            array(18),
53
            array(19),
54
            array(20),
55
            array(21),
56
            array(23),
57
            array(24),
58
            array(25),
59
            array(26),
60
            array(27),
61
            array(28),
62
            array(29),
63
            array(30),
64
            array(32),
65
            array(33),
66
        );
67
    }
68
69
70
    /**
71
     * testNoViolation
72
     *
73
     * @group emptyNonVariable
74
     *
75
     * @dataProvider dataNoViolation
76
     *
77
     * @param int $line The line number.
78
     *
79
     * @return void
80
     */
81
    public function testNoViolation($line)
82
    {
83
        $file = $this->sniffFile(self::TEST_FILE, '5.3');
84
        $this->assertNoViolation($file, $line);
85
    }
86
87
    /**
88
     * Data provider.
89
     *
90
     * @see testNoViolation()
91
     *
92
     * @return array
93
     */
94 View Code Duplication
    public function dataNoViolation()
0 ignored issues
show
Duplication introduced by
This method 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...
95
    {
96
        return array(
97
            array(4),
98
            array(5),
99
            array(6),
100
            array(7),
101
            array(8),
102
            array(9),
103
            array(10),
104
            array(11),
105
            array(12),
106
        );
107
    }
108
}
109