1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* CodingStandard_Tests_Commenting_InlineCommentUnitTest. |
4
|
|
|
* |
5
|
|
|
* PHP version 5 |
6
|
|
|
* |
7
|
|
|
* @category PHP |
8
|
|
|
* @package PHP_CodeSniffer |
9
|
|
|
* @author Greg Sherwood <[email protected]> |
10
|
|
|
* @author Marc McIntyre <[email protected]> |
11
|
|
|
* @author Alexander Obuhovich <[email protected]> |
12
|
|
|
* @license https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause |
13
|
|
|
* @link https://github.com/aik099/CodingStandard |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace CodingStandard\Tests\Commenting; |
17
|
|
|
|
18
|
|
|
use TestSuite\AbstractSniffUnitTest; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Unit test class for the InlineComment sniff. |
22
|
|
|
* |
23
|
|
|
* A sniff unit test checks a .inc file for expected violations of a single |
24
|
|
|
* coding standard. Expected errors and warnings are stored in this class. |
25
|
|
|
* |
26
|
|
|
* @category PHP |
27
|
|
|
* @package PHP_CodeSniffer |
28
|
|
|
* @author Greg Sherwood <[email protected]> |
29
|
|
|
* @author Marc McIntyre <[email protected]> |
30
|
|
|
* @author Alexander Obuhovich <[email protected]> |
31
|
|
|
* @license https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause |
32
|
|
|
* @link https://github.com/aik099/CodingStandard |
33
|
|
|
*/ |
34
|
|
|
class InlineCommentUnitTest extends AbstractSniffUnitTest |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns the lines where errors should occur. |
40
|
|
|
* |
41
|
|
|
* The key of the array should represent the line number and the value |
42
|
|
|
* should represent the number of errors that should occur on that line. |
43
|
|
|
* |
44
|
|
|
* @param string $testFile The name of the file being tested. |
45
|
|
|
* |
46
|
|
|
* @return array(int => int) |
47
|
|
|
*/ |
48
|
|
|
public function getErrorList($testFile) |
49
|
|
|
{ |
50
|
|
|
switch ($testFile) { |
51
|
|
|
case 'InlineCommentUnitTest.inc': |
52
|
|
|
$errors = array( |
53
|
|
|
17 => 1, |
54
|
|
|
27 => 1, |
55
|
|
|
28 => 1, |
56
|
|
|
32 => 2, |
57
|
|
|
36 => 1, |
58
|
|
|
44 => 2, |
59
|
|
|
54 => 1, |
60
|
|
|
58 => 1, |
61
|
|
|
61 => 1, |
62
|
|
|
64 => 1, |
63
|
|
|
67 => 1, |
64
|
|
|
95 => 1, |
65
|
|
|
96 => 1, |
66
|
|
|
97 => 2, |
67
|
|
|
// The @var inline comments are allowed. |
68
|
|
|
118 => 0, |
69
|
|
|
130 => 1, |
70
|
|
|
133 => 1, |
71
|
|
|
156 => 1, |
72
|
|
|
// Comments starting with non-letter are allowed. |
73
|
|
|
159 => 0, |
74
|
|
|
162 => 0, |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
return $errors; |
78
|
|
|
|
79
|
|
|
case 'InlineCommentUnitTest.js': |
80
|
|
|
return array( |
81
|
|
|
31 => 1, |
82
|
|
|
36 => 2, |
83
|
|
|
44 => 1, |
84
|
|
|
48 => 1, |
85
|
|
|
51 => 1, |
86
|
|
|
54 => 1, |
87
|
|
|
57 => 1, |
88
|
|
|
102 => 1, |
89
|
|
|
103 => 1, |
90
|
|
|
104 => 3, |
91
|
|
|
// Comments starting with digit are allowed. |
92
|
|
|
113 => 0, |
93
|
|
|
); |
94
|
|
|
}//end switch |
95
|
|
|
|
96
|
|
|
return array(); |
97
|
|
|
}//end getErrorList() |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Returns the lines where warnings should occur. |
102
|
|
|
* |
103
|
|
|
* The key of the array should represent the line number and the value |
104
|
|
|
* should represent the number of warnings that should occur on that line. |
105
|
|
|
* |
106
|
|
|
* @param string $testFile The name of the file being tested. |
107
|
|
|
* |
108
|
|
|
* @return array(int => int) |
109
|
|
|
*/ |
110
|
|
|
public function getWarningList($testFile) |
111
|
|
|
{ |
112
|
|
|
return array(); |
113
|
|
|
}//end getWarningList() |
114
|
|
|
}//end class |
115
|
|
|
|