-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
ForbiddenEmptyListAssignmentSniffTest.php
115 lines (104 loc) · 2.5 KB
/
ForbiddenEmptyListAssignmentSniffTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* Empty list() assignments have been removed in PHP 7.0 sniff test file
*
* @package PHPCompatibility
*/
namespace PHPCompatibility\Tests\Sniffs\PHP;
use PHPCompatibility\Tests\BaseSniffTest;
/**
* Empty list() assignments have been removed in PHP 7.0 sniff test file
*
* @group forbiddenEmptyListAssignment
* @group listAssignments
*
* @covers \PHPCompatibility\Sniffs\PHP\ForbiddenEmptyListAssignmentSniff
*
* @uses \PHPCompatibility\Tests\BaseSniffTest
* @package PHPCompatibility
* @author Wim Godden <wim@cu.be>
*/
class ForbiddenEmptyListAssignmentSniffTest extends BaseSniffTest
{
const TEST_FILE = 'sniff-examples/forbidden_empty_list_assignment.php';
/**
* testEmptyListAssignment
*
* @dataProvider dataEmptyListAssignment
*
* @param int $line Line number where the error should occur.
*
* @return void
*/
public function testEmptyListAssignment($line)
{
$file = $this->sniffFile(self::TEST_FILE, '7.0');
$this->assertError($file, $line, 'Empty list() assignments are not allowed since PHP 7.0');
}
/**
* dataEmptyListAssignment
*
* @see testEmptyListAssignment()
*
* @return array
*/
public function dataEmptyListAssignment()
{
return array(
array(3),
array(4),
array(5),
array(6),
array(7),
array(8),
array(20),
array(21),
array(22),
array(23),
array(24),
array(25),
);
}
/**
* testNoFalsePositives
*
* @dataProvider dataNoFalsePositives
*
* @param int $line Line number with a valid list assignment.
*
* @return void
*/
public function testNoFalsePositives($line)
{
$file = $this->sniffFile(self::TEST_FILE, '7.0');
$this->assertNoViolation($file, $line);
}
/**
* dataNoFalsePositives
*
* @see testNoFalsePositives()
*
* @return array
*/
public function dataNoFalsePositives()
{
return array(
array(13),
array(14),
array(15),
array(16),
array(17),
array(28),
);
}
/**
* Verify no notices are thrown at all.
*
* @return void
*/
public function testNoViolationsInFileOnValidVersion()
{
$file = $this->sniffFile(self::TEST_FILE, '5.6');
$this->assertNoViolation($file);
}
}