Skip to content

Commit b55a9ba

Browse files
committed
F
1 parent 65b18e5 commit b55a9ba

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

tests/Core/Ruleset/RegisterSniffsTest.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ final class RegisterSniffsTest extends TestCase
4141
* @var array<string>
4242
*/
4343
private static $psr1SniffFiles = [
44+
'Generic/Sniffs/Files/ByteOrderMarkSniff.php',
45+
'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
46+
'Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php',
47+
'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
4448
'PSR1/Sniffs/Classes/ClassDeclarationSniff.php',
4549
'PSR1/Sniffs/Files/SideEffectsSniff.php',
4650
'PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php',
47-
'Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php',
48-
'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
49-
'Generic/Sniffs/Files/ByteOrderMarkSniff.php',
5051
'Squiz/Sniffs/Classes/ValidClassNameSniff.php',
51-
'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
5252
];
5353

5454
/**
@@ -72,9 +72,13 @@ public static function initializeConfigAndRuleset()
7272
$config = new ConfigDouble(['--standard=PSR1']);
7373
self::$ruleset = new Ruleset($config);
7474

75-
// Remember the original value of the Ruleset::$sniff property as the tests may adjust it.
75+
// Remember the original value of the Ruleset::$sniff property as the tests adjust it.
7676
self::$originalSniffs = self::$ruleset->sniffs;
7777

78+
// Sort the value to make the tests stable as different OSes will read directories
79+
// in a different order and the order is not relevant for these tests. Just the values.
80+
ksort(self::$originalSniffs);
81+
7882
// Update the sniff file list.
7983
$standardsDir = dirname(dirname(dirname(__DIR__))).DIRECTORY_SEPARATOR;
8084
$standardsDir .= 'src'.DIRECTORY_SEPARATOR.'Standards'.DIRECTORY_SEPARATOR;
@@ -179,14 +183,17 @@ public function testRegisteredSniffsWithExclusions()
179183
$ruleset = new Ruleset($config);
180184

181185
$expected = [
186+
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff',
187+
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff',
182188
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowAlternativePHPTagsSniff',
183189
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff',
184-
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff',
185190
'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff',
186-
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff',
187191
];
188192

189-
$this->assertSame($expected, array_keys($ruleset->sniffs));
193+
$actual = array_keys($ruleset->sniffs);
194+
sort($actual);
195+
196+
$this->assertSame($expected, $actual);
190197

191198
}//end testRegisteredSniffsWithExclusions()
192199

@@ -213,8 +220,8 @@ public function testRegisteredSniffsBothRestrictionsAndExclusions()
213220
];
214221

215222
$expected = [
216-
'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff',
217223
'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff',
224+
'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff',
218225
];
219226

220227
self::$ruleset->registerSniffs(self::$psr1SniffAbsolutePaths, $restrictions, $exclusions);
@@ -262,7 +269,7 @@ public function testRegisteredSniffsFiltersOutFilePathsWithoutSniffsDir()
262269
$extraPathsBaseDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR;
263270
$extraPaths = [
264271
'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/NotInSniffsDirSniff.php',
265-
'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/SubDir\NotInSniffsDirSniff.php',
272+
'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/SubDir/NotInSniffsDirSniff.php',
266273
];
267274
$extraPaths = self::relativeToAbsoluteSniffFiles($extraPathsBaseDir, $extraPaths);
268275

0 commit comments

Comments
 (0)