@@ -47,35 +47,37 @@ final class RuleInclusionTest extends TestCase
4747 /**
4848 * Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file.
4949 *
50- * @beforeClass
50+ * @before
5151 *
5252 * @return void
5353 */
5454 public static function initializeConfigAndRuleset ()
5555 {
56- $ standard = __DIR__ .'/ ' .basename (__FILE__ , '.php ' ).'.xml ' ;
57- self ::$ standard = $ standard ;
56+ if (self ::$ standard === '' ) {
57+ $ standard = __DIR__ .'/ ' .basename (__FILE__ , '.php ' ).'.xml ' ;
58+ self ::$ standard = $ standard ;
5859
59- // On-the-fly adjust the ruleset test file to be able to test
60- // sniffs included with relative paths.
61- $ contents = file_get_contents ($ standard );
62- self ::$ contents = $ contents ;
60+ // On-the-fly adjust the ruleset test file to be able to test
61+ // sniffs included with relative paths.
62+ $ contents = file_get_contents ($ standard );
63+ self ::$ contents = $ contents ;
6364
64- $ repoRootDir = basename (dirname (dirname (dirname (__DIR__ ))));
65+ $ repoRootDir = basename (dirname (dirname (dirname (__DIR__ ))));
6566
66- $ newPath = $ repoRootDir ;
67- if (DIRECTORY_SEPARATOR === '\\' ) {
68- $ newPath = str_replace ('\\' , '/ ' , $ repoRootDir );
69- }
67+ $ newPath = $ repoRootDir ;
68+ if (DIRECTORY_SEPARATOR === '\\' ) {
69+ $ newPath = str_replace ('\\' , '/ ' , $ repoRootDir );
70+ }
7071
71- $ adjusted = str_replace ('%path_root_dir% ' , $ newPath , $ contents );
72+ $ adjusted = str_replace ('%path_root_dir% ' , $ newPath , $ contents );
7273
73- if (file_put_contents ($ standard , $ adjusted ) === false ) {
74- self ::markTestSkipped ('On the fly ruleset adjustment failed ' );
75- }
74+ if (file_put_contents ($ standard , $ adjusted ) === false ) {
75+ self ::markTestSkipped ('On the fly ruleset adjustment failed ' );
76+ }
7677
77- $ config = new ConfigDouble (["--standard= $ standard " ]);
78- self ::$ ruleset = new Ruleset ($ config );
78+ $ config = new ConfigDouble (["--standard= $ standard " ]);
79+ self ::$ ruleset = new Ruleset ($ config );
80+ }//end if
7981
8082 }//end initializeConfigAndRuleset()
8183
@@ -101,7 +103,7 @@ public function resetRuleset()
101103 */
102104 public function testHasSniffCodes ()
103105 {
104- $ this ->assertCount (48 , self ::$ ruleset ->sniffCodes );
106+ $ this ->assertCount (49 , self ::$ ruleset ->sniffCodes );
105107
106108 }//end testHasSniffCodes()
107109
@@ -318,6 +320,10 @@ public static function dataRegisteredSniffCodes()
318320 'Generic.Metrics.CyclomaticComplexity ' ,
319321 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff ' ,
320322 ],
323+ [
324+ 'Squiz.Files.FileExtension ' ,
325+ 'PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff ' ,
326+ ],
321327 [
322328 'Generic.NamingConventions.CamelCapsFunctionName ' ,
323329 'PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff ' ,
@@ -468,6 +474,10 @@ public static function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilen
468474 'sniffClass ' => 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff ' ,
469475 'propertyName ' => 'setforallincategory ' ,
470476 ],
477+ 'Set property for all sniffs in included category directory ' => [
478+ 'sniffClass ' => 'PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff ' ,
479+ 'propertyName ' => 'setforsquizfilessniffs ' ,
480+ ],
471481 ];
472482
473483 }//end dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails()
0 commit comments