@@ -108,7 +108,6 @@ public static function dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTes
108108 'Unqualified class name ' => ['ClassName ' ],
109109 'Fully qualified class name, not enough parts ' => ['Fully \\Qualified \\ClassName ' ],
110110 'Fully qualified class name, doesn \'t end on Sniff or UnitTest ' => ['Fully \\Sniffs \\Qualified \\ClassName ' ],
111- 'Fully qualified class name, ends on Sniff, but isn \'t ' => ['Fully \\Sniffs \\AbstractSomethingSniff ' ],
112111 ];
113112
114113 }//end dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass()
@@ -141,30 +140,58 @@ public function testGetSniffCode($fqnClass, $expected)
141140 public static function dataGetSniffCode ()
142141 {
143142 return [
144- 'PHPCS native sniff ' => [
143+ 'PHPCS native sniff ' => [
145144 'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Sniffs \\Arrays \\ArrayIndentSniff ' ,
146145 'expected ' => 'Generic.Arrays.ArrayIndent ' ,
147146 ],
148- 'Class is a PHPCS native test class ' => [
147+ 'Class is a PHPCS native test class ' => [
149148 'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Tests \\Arrays \\ArrayIndentUnitTest ' ,
150149 'expected ' => 'Generic.Arrays.ArrayIndent ' ,
151150 ],
152- 'Sniff in external standard without namespace prefix ' => [
151+ 'Sniff in external standard without namespace prefix ' => [
153152 'fqnClass ' => 'MyStandard \\Sniffs \\PHP \\MyNameSniff ' ,
154153 'expected ' => 'MyStandard.PHP.MyName ' ,
155154 ],
156- 'Test in external standard without namespace prefix ' => [
155+ 'Test in external standard without namespace prefix ' => [
157156 'fqnClass ' => 'MyStandard \\Tests \\PHP \\MyNameSniff ' ,
158157 'expected ' => 'MyStandard.PHP.MyName ' ,
159158 ],
160- 'Sniff in external standard with namespace prefix ' => [
159+ 'Sniff in external standard with namespace prefix ' => [
161160 'fqnClass ' => 'Vendor \\Package \\MyStandard \\Sniffs \\Category \\AnalyzeMeSniff ' ,
162161 'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
163162 ],
164- 'Test in external standard with namespace prefix ' => [
163+ 'Test in external standard with namespace prefix ' => [
165164 'fqnClass ' => 'Vendor \\Package \\MyStandard \\Tests \\Category \\AnalyzeMeUnitTest ' ,
166165 'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
167166 ],
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+ ],
168195 ];
169196
170197 }//end dataGetSniffCode()
0 commit comments