@@ -47,35 +47,37 @@ final class RuleInclusionTest extends TestCase
47
47
/**
48
48
* Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file.
49
49
*
50
- * @beforeClass
50
+ * @before
51
51
*
52
52
* @return void
53
53
*/
54
54
public static function initializeConfigAndRuleset ()
55
55
{
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 ;
58
59
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 ;
63
64
64
- $ repoRootDir = basename (dirname (dirname (dirname (__DIR__ ))));
65
+ $ repoRootDir = basename (dirname (dirname (dirname (__DIR__ ))));
65
66
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
+ }
70
71
71
- $ adjusted = str_replace ('%path_root_dir% ' , $ newPath , $ contents );
72
+ $ adjusted = str_replace ('%path_root_dir% ' , $ newPath , $ contents );
72
73
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
+ }
76
77
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
79
81
80
82
}//end initializeConfigAndRuleset()
81
83
@@ -101,7 +103,7 @@ public function resetRuleset()
101
103
*/
102
104
public function testHasSniffCodes ()
103
105
{
104
- $ this ->assertCount (48 , self ::$ ruleset ->sniffCodes );
106
+ $ this ->assertCount (49 , self ::$ ruleset ->sniffCodes );
105
107
106
108
}//end testHasSniffCodes()
107
109
@@ -318,6 +320,10 @@ public static function dataRegisteredSniffCodes()
318
320
'Generic.Metrics.CyclomaticComplexity ' ,
319
321
'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff ' ,
320
322
],
323
+ [
324
+ 'Squiz.Files.FileExtension ' ,
325
+ 'PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff ' ,
326
+ ],
321
327
[
322
328
'Generic.NamingConventions.CamelCapsFunctionName ' ,
323
329
'PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff ' ,
@@ -468,6 +474,10 @@ public static function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilen
468
474
'sniffClass ' => 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff ' ,
469
475
'propertyName ' => 'setforallincategory ' ,
470
476
],
477
+ 'Set property for all sniffs in included category directory ' => [
478
+ 'sniffClass ' => 'PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff ' ,
479
+ 'propertyName ' => 'setforsquizfilessniffs ' ,
480
+ ],
471
481
];
472
482
473
483
}//end dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails()
0 commit comments