|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* CodingStandard_Tests_ControlStructures_ControlSignatureUnitTest. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* @category PHP |
|
8
|
|
|
* @package PHP_CodeSniffer |
|
9
|
|
|
* @author Alexander Obuhovich <[email protected]> |
|
10
|
|
|
* @license https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause |
|
11
|
|
|
* @link https://github.com/aik099/CodingStandard |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace CodingStandard\Tests\ControlStructures; |
|
15
|
|
|
|
|
16
|
|
|
use TestSuite\AbstractSniffUnitTest; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Unit test class for the ControlSignature sniff. |
|
20
|
|
|
* |
|
21
|
|
|
* A sniff unit test checks a .inc file for expected violations of a single |
|
22
|
|
|
* coding standard. Expected errors and warnings are stored in this class. |
|
23
|
|
|
* |
|
24
|
|
|
* @category PHP |
|
25
|
|
|
* @package PHP_CodeSniffer |
|
26
|
|
|
* @author Alexander Obuhovich <[email protected]> |
|
27
|
|
|
* @license https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause |
|
28
|
|
|
* @link https://github.com/aik099/CodingStandard |
|
29
|
|
|
*/ |
|
30
|
|
|
class ControlSignatureUnitTest extends AbstractSniffUnitTest |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Returns the lines where errors should occur. |
|
36
|
|
|
* |
|
37
|
|
|
* The key of the array should represent the line number and the value |
|
38
|
|
|
* should represent the number of errors that should occur on that line. |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $testFile Name of the file with test data. |
|
41
|
|
|
* |
|
42
|
|
|
* @return array(int => int) |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getErrorList($testFile) |
|
45
|
|
|
{ |
|
46
|
|
|
return array( |
|
47
|
|
|
// The "do ... while" construct. |
|
48
|
|
|
5 => 1, |
|
49
|
|
|
7 => 1, |
|
50
|
|
|
10 => 1, |
|
51
|
|
|
12 => 1, |
|
52
|
|
|
14 => 1, |
|
53
|
|
|
17 => 1, |
|
54
|
|
|
// The "while" construct. |
|
55
|
|
|
23 => 1, |
|
56
|
|
|
25 => 1, |
|
57
|
|
|
27 => 1, |
|
58
|
|
|
// The "switch" construct. |
|
59
|
|
|
33 => 1, |
|
60
|
|
|
35 => 1, |
|
61
|
|
|
37 => 1, |
|
62
|
|
|
// The "for" construct. |
|
63
|
|
|
43 => 1, |
|
64
|
|
|
45 => 1, |
|
65
|
|
|
47 => 1, |
|
66
|
|
|
// The "if" construct. |
|
67
|
|
|
53 => 1, |
|
68
|
|
|
55 => 1, |
|
69
|
|
|
57 => 1, |
|
70
|
|
|
// The "foreach" construct. |
|
71
|
|
|
63 => 1, |
|
72
|
|
|
65 => 1, |
|
73
|
|
|
67 => 1, |
|
74
|
|
|
// The "elseif" construct. |
|
75
|
|
|
76 => 1, |
|
76
|
|
|
80 => 1, |
|
77
|
|
|
84 => 1, |
|
78
|
|
|
88 => 1, |
|
79
|
|
|
// The "else" construct. |
|
80
|
|
|
97 => 1, |
|
81
|
|
|
101 => 1, |
|
82
|
|
|
105 => 1, |
|
83
|
|
|
// The "do" construct. |
|
84
|
|
|
111 => 1, |
|
85
|
|
|
113 => 1, |
|
86
|
|
|
// The "try" construct. |
|
87
|
|
|
121 => 1, |
|
88
|
|
|
125 => 1, |
|
89
|
|
|
// The "catch" construct. |
|
90
|
|
|
136 => 1, |
|
91
|
|
|
139 => 1, |
|
92
|
|
|
143 => 1, |
|
93
|
|
|
147 => 1, |
|
94
|
|
|
); |
|
95
|
|
|
}//end getErrorList() |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Returns the lines where warnings should occur. |
|
100
|
|
|
* |
|
101
|
|
|
* The key of the array should represent the line number and the value |
|
102
|
|
|
* should represent the number of warnings that should occur on that line. |
|
103
|
|
|
* |
|
104
|
|
|
* @param string $testFile Name of the file with test data. |
|
105
|
|
|
* |
|
106
|
|
|
* @return array(int => int) |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getWarningList($testFile) |
|
109
|
|
|
{ |
|
110
|
|
|
return array(); |
|
111
|
|
|
}//end getWarningList() |
|
112
|
|
|
}//end class |
|
113
|
|
|
|