/
opt
/
cpanel
/
ea-wappspector
/
vendor
/
squizlabs
/
php_codesniffer
/
tests
/
Core
/
Ruleset
/
/opt/cpanel/ea-wappspector/vendor/squizlabs/php_codesniffer/tests/Core/Ruleset
mkdir
upload
Name
Size
Mode
Actions
Fixtures/
-
0755
rm
AbstractRulesetTestCase.php
3922
0644
edit
dl
rm
ConstructorNoSniffsTest.xml
217
0644
edit
dl
rm
ConstructorTest.php
11381
0644
edit
dl
rm
DisplayCachedMessagesTest.php
11086
0644
edit
dl
rm
ExpandRulesetReferenceCaseMismatch1Test.xml
512
0644
edit
dl
rm
ExpandRulesetReferenceCaseMismatch2Test.xml
547
0644
edit
dl
rm
ExpandRulesetReferenceHomePathFailTest.xml
425
0644
edit
dl
rm
ExpandRulesetReferenceHomePathTest.php
3559
0644
edit
dl
rm
ExpandRulesetReferenceHomePathTest.xml
337
0644
edit
dl
rm
ExpandRulesetReferenceInternalIgnoreTest.xml
643
0644
edit
dl
rm
ExpandRulesetReferenceInternalStandardTest.xml
330
0644
edit
dl
rm
ExpandRulesetReferenceInternalTest.php
2573
0644
edit
dl
rm
ExpandRulesetReferenceInvalidErrorCode1Test.xml
332
0644
edit
dl
rm
ExpandRulesetReferenceInvalidErrorCode2Test.xml
333
0644
edit
dl
rm
ExpandRulesetReferenceInvalidErrorCode3Test.xml
325
0644
edit
dl
rm
ExpandRulesetReferenceInvalidHomePathRefTest.xml
434
0644
edit
dl
rm
ExpandRulesetReferenceMissingFileTest.xml
364
0644
edit
dl
rm
ExpandRulesetReferenceTest.php
5481
0644
edit
dl
rm
ExpandRulesetReferenceTest.xml
621
0644
edit
dl
rm
ExpandRulesetReferenceUnknownCategoryTest.xml
508
0644
edit
dl
rm
ExpandRulesetReferenceUnknownSniffTest.xml
515
0644
edit
dl
rm
ExpandRulesetReferenceUnknownStandardTest.xml
469
0644
edit
dl
rm
ExpandSniffDirectoryTest.php
2545
0644
edit
dl
rm
ExpandSniffDirectoryTest.xml
349
0644
edit
dl
rm
ExplainCustomRulesetTest.xml
374
0644
edit
dl
rm
ExplainSingleSniffTest.xml
247
0644
edit
dl
rm
ExplainTest.php
8357
0644
edit
dl
rm
GetIgnorePatternsTest.php
3502
0644
edit
dl
rm
GetIgnorePatternsTest.xml
742
0644
edit
dl
rm
GetIncludePatternsTest.php
3306
0644
edit
dl
rm
GetIncludePatternsTest.xml
556
0644
edit
dl
rm
PopulateTokenListenersNamingConventionsTest.php
4777
0644
edit
dl
rm
PopulateTokenListenersNamingConventionsTest.xml
1590
0644
edit
dl
rm
PopulateTokenListenersRegisterNoArrayTest.xml
465
0644
edit
dl
rm
PopulateTokenListenersSupportedTokenizersTest.php
4234
0644
edit
dl
rm
PopulateTokenListenersSupportedTokenizersTest.xml
369
0644
edit
dl
rm
PopulateTokenListenersTest.php
21569
0644
edit
dl
rm
PopulateTokenListenersTest.xml
2034
0644
edit
dl
rm
ProcessRuleInvalidTypeTest.php
1206
0644
edit
dl
rm
ProcessRuleInvalidTypeTest.xml
345
0644
edit
dl
rm
ProcessRulesetAutoExpandSniffsDirectoryTest.xml
592
0644
edit
dl
rm
ProcessRulesetAutoloadFileNotFoundTest.xml
394
0644
edit
dl
rm
ProcessRulesetAutoloadTest.php
6268
0644
edit
dl
rm
ProcessRulesetAutoloadTest.xml
1419
0644
edit
dl
rm
ProcessRulesetBrokenRulesetEmptyFileTest.xml
0
0644
edit
dl
rm
ProcessRulesetBrokenRulesetMultiErrorTest.xml
420
0644
edit
dl
rm
ProcessRulesetBrokenRulesetSingleErrorTest.xml
201
0644
edit
dl
rm
ProcessRulesetBrokenRulesetTest.php
3207
0644
edit
dl
rm
ProcessRulesetExcludeSniffGroupTest.xml
362
0644
edit
dl
rm
ProcessRulesetInvalidNoSniffsDirTest.xml
439
0644
edit
dl
rm
ProcessRulesetMiscTest.xml
997
0644
edit
dl
rm
ProcessRulesetShouldProcessElementTest.php
12727
0644
edit
dl
rm
ProcessRulesetShouldProcessElementTest.xml
1710
0644
edit
dl
rm
ProcessRulesetTest.php
11509
0644
edit
dl
rm
ProcessRuleShouldProcessElementTest.php
25307
0644
edit
dl
rm
ProcessRuleShouldProcessElementTest.xml
3392
0644
edit
dl
rm
PropertyTypeHandlingInlineTest.xml
317
0644
edit
dl
rm
PropertyTypeHandlingTest.php
12324
0644
edit
dl
rm
PropertyTypeHandlingTest.xml
3901
0644
edit
dl
rm
RegisterSniffsMissingInterfaceInvalidTest.xml
355
0644
edit
dl
rm
RegisterSniffsMissingInterfaceTest.php
2135
0644
edit
dl
rm
RegisterSniffsMissingInterfaceValidTest.xml
446
0644
edit
dl
rm
RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml
444
0644
edit
dl
rm
RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml
454
0644
edit
dl
rm
RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml
445
0644
edit
dl
rm
RegisterSniffsRejectsInvalidSniffTest.php
2776
0644
edit
dl
rm
RegisterSniffsTest.php
10519
0644
edit
dl
rm
RuleInclusionAbsoluteLinuxTest.php
3358
0644
edit
dl
rm
RuleInclusionAbsoluteLinuxTest.xml
482
0644
edit
dl
rm
RuleInclusionAbsoluteWindowsTest.php
3270
0644
edit
dl
rm
RuleInclusionAbsoluteWindowsTest.xml
479
0644
edit
dl
rm
RuleInclusionTest-include.xml
364
0644
edit
dl
rm
RuleInclusionTest.php
19001
0644
edit
dl
rm
RuleInclusionTest.xml
1883
0644
edit
dl
rm
SetPropertyAllowedAsDeclaredTest.xml
728
0644
edit
dl
rm
SetPropertyAllowedViaMagicMethodTest.xml
732
0644
edit
dl
rm
SetPropertyAllowedViaStdClassTest.xml
729
0644
edit
dl
rm
SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml
338
0644
edit
dl
rm
SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml
343
0644
edit
dl
rm
SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml
376
0644
edit
dl
rm
SetPropertyNotAllowedViaAttributeTest.xml
439
0644
edit
dl
rm
SetPropertyThrowsErrorOnInvalidPropertyTest.xml
354
0644
edit
dl
rm
SetSniffPropertyTest.php
17128
0644
edit
dl
rm
ShowSniffDeprecationsEmptyDeprecationVersionTest.xml
371
0644
edit
dl
rm
ShowSniffDeprecationsEmptyRemovalVersionTest.xml
367
0644
edit
dl
rm
ShowSniffDeprecationsInvalidDeprecationMessageTest.xml
373
0644
edit
dl
rm
ShowSniffDeprecationsInvalidDeprecationVersionTest.xml
373
0644
edit
dl
rm
ShowSniffDeprecationsInvalidRemovalVersionTest.xml
369
0644
edit
dl
rm
ShowSniffDeprecationsOrderTest.xml
513
0644
edit
dl
rm
ShowSniffDeprecationsReportWidthTest.xml
360
0644
edit
dl
rm
ShowSniffDeprecationsTest.php
26222
0644
edit
dl
rm
ShowSniffDeprecationsTest.xml
622
0644
edit
dl
rm
Edit:
/opt/cpanel/ea-wappspector/vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ConstructorTest.php
(11381B)
<?php /** * Test the Ruleset::__construct() method. * * @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl> * @copyright 2024 PHPCSStandards and contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; use PHP_CodeSniffer\Autoload; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; /** * Test various aspects of the Ruleset::__construct() method not covered via other tests. * * @covers \PHP_CodeSniffer\Ruleset::__construct */ final class ConstructorTest extends AbstractRulesetTestCase { /** * Test setting the ruleset name. * * @param array<string> $cliArgs The CLI args to pass to the Config. * @param string $expected The expected set ruleset name. * * @dataProvider dataHandlingStandardsPassedViaCLI * * @return void */ public function testHandlingStandardsPassedViaCLI($cliArgs, $expected) { $config = new ConfigDouble($cliArgs); $ruleset = new Ruleset($config); $this->assertSame($expected, $ruleset->name); }//end testHandlingStandardsPassedViaCLI() /** * Data provider. * * @see testHandlingStandardsPassedViaCLI() * * @return array<string, array<string, string|array<string>>> */ public static function dataHandlingStandardsPassedViaCLI() { return [ 'Single standard passed' => [ 'cliArgs' => ['--standard=PSR1'], 'expected' => 'PSR1', ], 'Multiple standards passed' => [ 'cliArgs' => ['--standard=PSR1,Zend'], 'expected' => 'PSR1, Zend', ], 'Absolute path to standard directory passed' => [ 'cliArgs' => [ '--standard='.__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'TestStandard', // Limit this to a valid sniff to prevent running into error messages unrelated to what // is being tested here. '--sniffs=TestStandard.ValidSniffs.RegisterEmptyArray', ], 'expected' => 'TestStandard', ], ]; }//end dataHandlingStandardsPassedViaCLI() /** * Verify that standards are registered with the Autoloader. * * @param array<string> $cliArgs The CLI args to pass to the Config. * @param array<string, string> $expected Minimum set of standards expected to be registered with the autoloader. * * @dataProvider dataStandardsAreRegisteredWithAutoloader * * @return void */ public function testStandardsAreRegisteredWithAutoloader($cliArgs, $expected) { $config = new ConfigDouble($cliArgs); new Ruleset($config); $autoloadPaths = Autoload::getSearchPaths(); // Note: doing a full comparison of the Autoloader registered standards would make this test unstable // as the `CodeSniffer.conf` of the user running the tests could interfer if they have additional // external standards registered. // Also note that `--runtime-set` is being used to set `installed_paths` to prevent making any changes to // the `CodeSniffer.conf` file of the user running the tests. foreach ($expected as $path => $namespacedStandardName) { $this->assertArrayHasKey($path, $autoloadPaths, "Path $path has not been registered with the autoloader"); $this->assertSame($namespacedStandardName, $autoloadPaths[$path], 'Expected (namespaced) standard name does not match'); } }//end testStandardsAreRegisteredWithAutoloader() /** * Data provider. * * @see testStandardsAreRegisteredWithAutoloader() * * @return array<string, array<string, array<int|string, string>>> */ public static function dataStandardsAreRegisteredWithAutoloader() { $basePath = dirname(dirname(dirname(__DIR__))).DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'Standards'.DIRECTORY_SEPARATOR; $defaultPaths = [ $basePath.'MySource' => 'MySource', $basePath.'PEAR' => 'PEAR', $basePath.'PSR1' => 'PSR1', $basePath.'PSR12' => 'PSR12', $basePath.'PSR2' => 'PSR2', $basePath.'Squiz' => 'Squiz', $basePath.'Zend' => 'Zend', ]; $data = [ 'Default standards' => [ 'cliArgs' => [ '--standard=PSR1', '--runtime-set installed_paths .', ], 'expected' => $defaultPaths, ], ]; $extraInstalledPath = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'DirectoryExpansion'; $extraInstalledPath .= DIRECTORY_SEPARATOR.'.hiddenAbove'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'MyStandard'; $data['Additional non-namespaced standard'] = [ 'cliArgs' => [ '--standard=MyStandard', '--runtime-set', 'installed_paths', $extraInstalledPath, ], 'expected' => ($defaultPaths + [$extraInstalledPath => 'MyStandard']), ]; $extraInstalledPath = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'TestStandard'; $data['Additional namespaced standard'] = [ 'cliArgs' => [ '--standard=TestStandard', '--runtime-set', 'installed_paths', $extraInstalledPath, // Limit this to a valid sniff to prevent running into error messages unrelated to what // is being tested here. '--sniffs=TestStandard.ValidSniffs.RegisterEmptyArray', ], 'expected' => ($defaultPaths + [$extraInstalledPath => 'Fixtures\TestStandard']), ]; return $data; }//end dataStandardsAreRegisteredWithAutoloader() /** * Verify handling of sniff restrictions in combination with the caching setting. * * @param array<string> $cliArgs The CLI args to pass to the Config. * @param bool $cache Whether to turn the cache on or off. * @param array<string> $expected Sniffs which are expected to have been registered. * * @dataProvider dataCachingVersusRestrictions * * @return void */ public function testCachingVersusRestrictions($cliArgs, $cache, $expected) { $config = new ConfigDouble($cliArgs); // Overrule the cache setting (which is being ignored in the Config when the tests are running). $config->cache = $cache; $ruleset = new Ruleset($config); $actual = array_keys($ruleset->sniffs); sort($actual); $this->assertSame($expected, $actual); }//end testCachingVersusRestrictions() /** * Data provider. * * Note: the test cases only use `--exclude` to restrict, * * @see testCachingVersusRestrictions() * * @return array<string, array<string, bool|array<string>>> */ public static function dataCachingVersusRestrictions() { $completeSet = [ '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\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Methods\\CamelCapsMethodNameSniff', 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff', ]; return [ 'No restrictions, cache off' => [ 'cliArgs' => ['--standard=PSR1'], 'cache' => false, 'expected' => $completeSet, ], 'Has exclusions, cache off' => [ 'cliArgs' => [ '--standard=PSR1', '--exclude=Generic.Files.ByteOrderMark,Generic.PHP.DisallowShortOpenTag,PSR1.Files.SideEffects,Generic.PHP.DisallowAlternativePHPTags', ], 'cache' => false, 'expected' => [ 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Methods\\CamelCapsMethodNameSniff', 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff', ], ], 'Has sniff selection, cache off' => [ 'cliArgs' => [ '--standard=PSR1', '--sniffs=Generic.Files.ByteOrderMark,Generic.PHP.DisallowShortOpenTag,PSR1.Files.SideEffects,Generic.PHP.DisallowAlternativePHPTags', ], 'cache' => false, 'expected' => [ 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff', 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowAlternativePHPTagsSniff', 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', ], ], 'No restrictions, cache on' => [ 'cliArgs' => ['--standard=PSR1'], 'cache' => true, 'expected' => $completeSet, ], 'Has exclusions, cache on' => [ 'cliArgs' => [ '--standard=PSR1', '--exclude=Generic.Files.ByteOrderMark,Generic.PHP.DisallowAlternativePHPTags,Generic.PHP.DisallowShortOpenTag,PSR1.Files.SideEffects', ], 'cache' => true, 'expected' => $completeSet, ], /* * "Has sniff selection, cache on" case cannot be tested due to the `Ruleset` class * containing special handling of sniff selection when the tests are running. */ ]; }//end dataCachingVersusRestrictions() /** * Test an exception is thrown when no sniffs have been registered via the ruleset. * * @return void */ public function testNoSniffsRegisteredException() { $standard = __DIR__.'/ConstructorNoSniffsTest.xml'; $config = new ConfigDouble(["--standard=$standard"]); $message = 'ERROR: No sniffs were registered.'.PHP_EOL.PHP_EOL; $this->expectRuntimeExceptionMessage($message); new Ruleset($config); }//end testNoSniffsRegisteredException() }//end class
Save
cmd:
run