From b55a9ba5660b1d1a59286d466445f3bfa15700d5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Nov 2024 03:32:11 +0100 Subject: [PATCH] F --- tests/Core/Ruleset/RegisterSniffsTest.php | 27 ++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/Core/Ruleset/RegisterSniffsTest.php b/tests/Core/Ruleset/RegisterSniffsTest.php index 8aa7afc7a0..75adf6e527 100644 --- a/tests/Core/Ruleset/RegisterSniffsTest.php +++ b/tests/Core/Ruleset/RegisterSniffsTest.php @@ -41,14 +41,14 @@ final class RegisterSniffsTest extends TestCase * @var array */ private static $psr1SniffFiles = [ + 'Generic/Sniffs/Files/ByteOrderMarkSniff.php', + 'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php', + 'Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php', + 'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php', 'PSR1/Sniffs/Classes/ClassDeclarationSniff.php', 'PSR1/Sniffs/Files/SideEffectsSniff.php', 'PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php', - 'Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php', - 'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php', - 'Generic/Sniffs/Files/ByteOrderMarkSniff.php', 'Squiz/Sniffs/Classes/ValidClassNameSniff.php', - 'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php', ]; /** @@ -72,9 +72,13 @@ public static function initializeConfigAndRuleset() $config = new ConfigDouble(['--standard=PSR1']); self::$ruleset = new Ruleset($config); - // Remember the original value of the Ruleset::$sniff property as the tests may adjust it. + // Remember the original value of the Ruleset::$sniff property as the tests adjust it. self::$originalSniffs = self::$ruleset->sniffs; + // Sort the value to make the tests stable as different OSes will read directories + // in a different order and the order is not relevant for these tests. Just the values. + ksort(self::$originalSniffs); + // Update the sniff file list. $standardsDir = dirname(dirname(dirname(__DIR__))).DIRECTORY_SEPARATOR; $standardsDir .= 'src'.DIRECTORY_SEPARATOR.'Standards'.DIRECTORY_SEPARATOR; @@ -179,14 +183,17 @@ public function testRegisteredSniffsWithExclusions() $ruleset = new Ruleset($config); $expected = [ + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowAlternativePHPTagsSniff', 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', - 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff', 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff', - 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', ]; - $this->assertSame($expected, array_keys($ruleset->sniffs)); + $actual = array_keys($ruleset->sniffs); + sort($actual); + + $this->assertSame($expected, $actual); }//end testRegisteredSniffsWithExclusions() @@ -213,8 +220,8 @@ public function testRegisteredSniffsBothRestrictionsAndExclusions() ]; $expected = [ - 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', ]; self::$ruleset->registerSniffs(self::$psr1SniffAbsolutePaths, $restrictions, $exclusions); @@ -262,7 +269,7 @@ public function testRegisteredSniffsFiltersOutFilePathsWithoutSniffsDir() $extraPathsBaseDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR; $extraPaths = [ 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/NotInSniffsDirSniff.php', - 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/SubDir\NotInSniffsDirSniff.php', + 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/SubDir/NotInSniffsDirSniff.php', ]; $extraPaths = self::relativeToAbsoluteSniffFiles($extraPathsBaseDir, $extraPaths);