Completed
Branch feature/scrutinizer-run-tests (072b5a)
by Juliette
10:12
created

EmptyNonVariableSniffTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 105
rs 10
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
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
    public function testEmptyNonVariable($line)
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(17),
51
            array(18),
52
53
            array(20),
54
            array(21),
55
            array(22),
56
            array(23),
57
58
            array(25),
59
            array(26),
60
            array(27),
61
            array(28),
62
            array(29),
63
            array(30),
64
            array(31),
65
            array(32),
66
67
            array(34),
68
            array(35),
69
            array(37),
70
            array(38),
71
            array(39),
72
            array(40),
73
74
            array(42),
75
            array(43),
76
        );
77
    }
78
79
80
    /**
81
     * testNoViolation
82
     *
83
     * @group emptyNonVariable
84
     *
85
     * @dataProvider dataNoViolation
86
     *
87
     * @param int $line The line number.
88
     *
89
     * @return void
90
     */
91
    public function testNoViolation($line)
92
    {
93
        $file = $this->sniffFile(self::TEST_FILE, '5.3');
94
        $this->assertNoViolation($file, $line);
95
    }
96
97
    /**
98
     * Data provider.
99
     *
100
     * @see testNoViolation()
101
     *
102
     * @return array
103
     */
104
    public function dataNoViolation()
105
    {
106
        return array(
107
            array(4),
108
            array(5),
109
            array(6),
110
            array(7),
111
            array(8),
112
            array(9),
113
            array(10),
114
            array(11),
115
            array(12),
116
            array(13),
117
            array(14),
118
        );
119
    }
120
}
121