@@ -105,9 +105,16 @@ public function testGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass(
105
105
public static function dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass ()
106
106
{
107
107
return [
108
- 'Unqualified class name ' => ['ClassName ' ],
109
- 'Fully qualified class name, not enough parts ' => ['Fully \\Qualified \\ClassName ' ],
108
+ 'Unqualified class name ' => ['ClassNameSniff ' ],
109
+ 'Fully qualified sniff class name, not enough parts [1] ' => ['Fully \\Qualified \\ClassNameSniff ' ],
110
+ 'Fully qualified sniff class name, not enough parts [2] ' => ['CompanyName \\CheckMeSniff ' ],
111
+ 'Fully qualified test class name, not enough parts ' => ['Fully \\Qualified \\ClassNameUnitTest ' ],
110
112
'Fully qualified class name, doesn \'t end on Sniff or UnitTest ' => ['Fully \\Sniffs \\Qualified \\ClassName ' ],
113
+ 'Fully qualified class name, ends on Sniff, but isn \'t ' => ['Fully \\Sniffs \\AbstractSomethingSniff ' ],
114
+ 'Fully qualified class name, last part *is* Sniff ' => ['CompanyName \\Sniffs \\Category \\Sniff ' ],
115
+ 'Fully qualified class name, last part *is* UnitTest ' => ['CompanyName \\Tests \\Category \\UnitTest ' ],
116
+ 'Fully qualified class name, no Sniffs or Tests leaf ' => ['CompanyName \\CustomSniffs \\Whatever \\CheckMeSniff ' ],
117
+ 'Fully qualified class name, category called Sniffs ' => ['CompanyName \\Sniffs \\Sniffs \\InvalidCategorySniff ' ],
111
118
];
112
119
113
120
}//end dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass()
@@ -140,70 +147,30 @@ public function testGetSniffCode($fqnClass, $expected)
140
147
public static function dataGetSniffCode ()
141
148
{
142
149
return [
143
- 'PHPCS native sniff ' => [
150
+ 'PHPCS native sniff ' => [
144
151
'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Sniffs \\Arrays \\ArrayIndentSniff ' ,
145
152
'expected ' => 'Generic.Arrays.ArrayIndent ' ,
146
153
],
147
- 'Class is a PHPCS native test class ' => [
154
+ 'Class is a PHPCS native test class ' => [
148
155
'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Tests \\Arrays \\ArrayIndentUnitTest ' ,
149
156
'expected ' => 'Generic.Arrays.ArrayIndent ' ,
150
157
],
151
- 'Sniff in external standard without namespace prefix ' => [
158
+ 'Sniff in external standard without namespace prefix ' => [
152
159
'fqnClass ' => 'MyStandard \\Sniffs \\PHP \\MyNameSniff ' ,
153
160
'expected ' => 'MyStandard.PHP.MyName ' ,
154
161
],
155
- 'Test in external standard without namespace prefix ' => [
162
+ 'Test in external standard without namespace prefix ' => [
156
163
'fqnClass ' => 'MyStandard \\Tests \\PHP \\MyNameUnitTest ' ,
157
164
'expected ' => 'MyStandard.PHP.MyName ' ,
158
165
],
159
- 'Sniff in external standard with namespace prefix ' => [
166
+ 'Sniff in external standard with namespace prefix ' => [
160
167
'fqnClass ' => 'Vendor \\Package \\MyStandard \\Sniffs \\Category \\AnalyzeMeSniff ' ,
161
168
'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
162
169
],
163
- 'Test in external standard with namespace prefix ' => [
170
+ 'Test in external standard with namespace prefix ' => [
164
171
'fqnClass ' => 'Vendor \\Package \\MyStandard \\Tests \\Category \\AnalyzeMeUnitTest ' ,
165
172
'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
166
173
],
167
-
168
- /*
169
- * These are not valid sniff codes and is an undesirable result, but can't be helped
170
- * as changing this would be a BC-break.
171
- * Supporting these to allow for <rule> tags directly including sniff files.
172
- * See: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/675
173
- */
174
-
175
- 'Fully qualified class name, ends on Sniff, but isn \'t ' => [
176
- 'fqnClass ' => 'Fully \\Sniffs \\AbstractSomethingSniff ' ,
177
- 'expected ' => '.Sniffs.AbstractSomething ' ,
178
- ],
179
- 'Sniff provided via file include and doesn \'t comply with naming conventions [1] ' => [
180
- 'fqnClass ' => 'CheckMeSniff ' ,
181
- 'expected ' => '..CheckMe ' ,
182
- ],
183
- 'Sniff provided via file include and doesn \'t comply with naming conventions [2] ' => [
184
- 'fqnClass ' => 'CompanyName \\CheckMeSniff ' ,
185
- 'expected ' => '.CompanyName.CheckMe ' ,
186
- ],
187
- 'Sniff provided via file include and doesn \'t comply with naming conventions [3] ' => [
188
- 'fqnClass ' => 'CompanyName \\Sniffs \\CheckMeSniff ' ,
189
- 'expected ' => '.Sniffs.CheckMe ' ,
190
- ],
191
- 'Sniff provided via file include and doesn \'t comply with naming conventions [4] ' => [
192
- 'fqnClass ' => 'CompanyName \\CustomSniffs \\Whatever \\CheckMeSniff ' ,
193
- 'expected ' => 'CompanyName.Whatever.CheckMe ' ,
194
- ],
195
- 'Sniff provided via file include and doesn \'t comply with naming conventions [5] ' => [
196
- 'fqnClass ' => 'CompanyName \\Sniffs \\Category \\Sniff ' ,
197
- 'expected ' => 'CompanyName.Category. ' ,
198
- ],
199
- 'Sniff provided via file include and doesn \'t comply with naming conventions [6] ' => [
200
- 'fqnClass ' => 'CompanyName \\Tests \\Category \\UnitTest ' ,
201
- 'expected ' => 'CompanyName.Category. ' ,
202
- ],
203
- 'Sniff provided via file include and doesn \'t comply with naming conventions [7] ' => [
204
- 'fqnClass ' => 'Sniffs \\Category \\NamedSniff ' ,
205
- 'expected ' => '.Category.Named ' ,
206
- ],
207
174
];
208
175
209
176
}//end dataGetSniffCode()
0 commit comments