@@ -105,9 +105,16 @@ public function testGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass(
105105 public static function dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass ()
106106 {
107107 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 ' ],
110112 '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 ' ],
111118 ];
112119
113120 }//end dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass()
@@ -140,70 +147,30 @@ public function testGetSniffCode($fqnClass, $expected)
140147 public static function dataGetSniffCode ()
141148 {
142149 return [
143- 'PHPCS native sniff ' => [
150+ 'PHPCS native sniff ' => [
144151 'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Sniffs \\Arrays \\ArrayIndentSniff ' ,
145152 'expected ' => 'Generic.Arrays.ArrayIndent ' ,
146153 ],
147- 'Class is a PHPCS native test class ' => [
154+ 'Class is a PHPCS native test class ' => [
148155 'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Tests \\Arrays \\ArrayIndentUnitTest ' ,
149156 'expected ' => 'Generic.Arrays.ArrayIndent ' ,
150157 ],
151- 'Sniff in external standard without namespace prefix ' => [
158+ 'Sniff in external standard without namespace prefix ' => [
152159 'fqnClass ' => 'MyStandard \\Sniffs \\PHP \\MyNameSniff ' ,
153160 'expected ' => 'MyStandard.PHP.MyName ' ,
154161 ],
155- 'Test in external standard without namespace prefix ' => [
162+ 'Test in external standard without namespace prefix ' => [
156163 'fqnClass ' => 'MyStandard \\Tests \\PHP \\MyNameUnitTest ' ,
157164 'expected ' => 'MyStandard.PHP.MyName ' ,
158165 ],
159- 'Sniff in external standard with namespace prefix ' => [
166+ 'Sniff in external standard with namespace prefix ' => [
160167 'fqnClass ' => 'Vendor \\Package \\MyStandard \\Sniffs \\Category \\AnalyzeMeSniff ' ,
161168 'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
162169 ],
163- 'Test in external standard with namespace prefix ' => [
170+ 'Test in external standard with namespace prefix ' => [
164171 'fqnClass ' => 'Vendor \\Package \\MyStandard \\Tests \\Category \\AnalyzeMeUnitTest ' ,
165172 'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
166173 ],
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- ],
207174 ];
208175
209176 }//end dataGetSniffCode()
0 commit comments