-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
NewListReferenceAssignmentUnitTest.php
117 lines (106 loc) · 2.63 KB
/
NewListReferenceAssignmentUnitTest.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
116
117
<?php
/**
* PHP 7.3 list reference assignments sniff test file.
*
* @package PHPCompatibility
*/
namespace PHPCompatibility\Tests\Sniffs\Lists;
use PHPCompatibility\Tests\BaseSniffTest;
/**
* PHP 7.3 list reference assignments sniff test file.
*
* @group newListReferenceAssignment
* @group lists
*
* @covers \PHPCompatibility\Sniffs\Lists\NewListReferenceAssignmentSniff
*
* @uses \PHPCompatibility\Tests\BaseSniffTest
* @package PHPCompatibility
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
*/
class NewListReferenceAssignmentUnitTest extends BaseSniffTest
{
const TEST_FILE = 'Sniffs/Lists/NewListReferenceAssignmentUnitTest.inc';
/**
* testNewListReferenceAssignment
*
* @dataProvider dataNewListReferenceAssignment
*
* @param int $line Line number where the error should occur.
*
* @return void
*/
public function testNewListReferenceAssignment($line)
{
$file = $this->sniffFile(self::TEST_FILE, '7.2');
$this->assertError($file, $line, 'Reference assignments within list constructs are not supported in PHP 7.2 or earlier.');
}
/**
* dataNewListReferenceAssignment
*
* @see testNewListReferenceAssignment()
*
* @return array
*/
public function dataNewListReferenceAssignment()
{
return array(
array(16),
array(17),
array(20),
array(24),
array(30),
array(33), // x2.
array(36), // x2.
array(37),
);
}
/**
* 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.2');
$this->assertNoViolation($file, $line);
}
/**
* dataNoFalsePositives
*
* @see testNoFalsePositives()
*
* @return array
*/
public function dataNoFalsePositives()
{
return array(
array(6),
array(7),
array(9),
array(10),
array(19),
array(21),
array(22),
array(23),
array(25),
array(29),
array(31),
array(32),
);
}
/**
* Verify no notices are thrown at all.
*
* @return void
*/
public function testNoViolationsInFileOnValidVersion()
{
$file = $this->sniffFile(self::TEST_FILE, '7.3');
$this->assertNoViolation($file);
}
}