PATH:
opt
/
cpanel
/
ea-wappspector
/
vendor
/
squizlabs
/
php_codesniffer
/
tests
/
Core
/
Ruleset
<?php /** * Tests for the \PHP_CodeSniffer\Ruleset class using a Linux-style absolute path to include a sniff. * * @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl> * @copyright 2019 Juliette Reinders Folmer. All rights reserved. * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; /** * Tests for the \PHP_CodeSniffer\Ruleset class using a Linux-style absolute path to include a sniff. * * @covers \PHP_CodeSniffer\Ruleset */ final class RuleInclusionAbsoluteLinuxTest extends TestCase { /** * The Ruleset object. * * @var \PHP_CodeSniffer\Ruleset */ protected $ruleset; /** * Path to the ruleset file. * * @var string */ private $standard = ''; /** * The original content of the ruleset. * * @var string */ private $contents = ''; /** * Initialize the config and ruleset objects. * * @before * * @return void */ protected function initializeConfigAndRuleset() { $this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $repoRootDir = dirname(dirname(dirname(__DIR__))); // On-the-fly adjust the ruleset test file to be able to test sniffs included with absolute paths. $contents = file_get_contents($this->standard); $this->contents = $contents; $newPath = $repoRootDir; if (DIRECTORY_SEPARATOR === '\\') { $newPath = str_replace('\\', '/', $repoRootDir); } $adjusted = str_replace('%path_slash_forward%', $newPath, $contents); if (file_put_contents($this->standard, $adjusted) === false) { $this->markTestSkipped('On the fly ruleset adjustment failed'); } // Initialize the config and ruleset objects for the test. $config = new ConfigDouble(["--standard={$this->standard}"]); $this->ruleset = new Ruleset($config); }//end initializeConfigAndRuleset() /** * Reset ruleset file. * * @after * * @return void */ protected function resetRuleset() { file_put_contents($this->standard, $this->contents); }//end resetRuleset() /** * Test that sniffs registed with a Linux absolute path are correctly recognized and that * properties are correctly set for them. * * @return void */ public function testLinuxStylePathRuleInclusion() { // Test that the sniff is correctly registered. $this->assertCount(1, $this->ruleset->sniffCodes); $this->assertArrayHasKey('Generic.Formatting.SpaceAfterNot', $this->ruleset->sniffCodes); $this->assertSame( 'PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff', $this->ruleset->sniffCodes['Generic.Formatting.SpaceAfterNot'] ); // Test that the sniff properties are correctly set. $this->assertSame( '10', $this->ruleset->sniffs['PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff']->spacing ); }//end testLinuxStylePathRuleInclusion() }//end class
[+]
..
[-] ProcessRulesetShouldProcessElementTest.xml
[edit]
[-] ProcessRulesetAutoExpandSniffsDirectoryTest.xml
[edit]
[-] ProcessRulesetExcludeSniffGroupTest.xml
[edit]
[-] PropertyTypeHandlingTest.xml
[edit]
[-] ExplainCustomRulesetTest.xml
[edit]
[-] ShowSniffDeprecationsInvalidDeprecationVersionTest.xml
[edit]
[-] RegisterSniffsMissingInterfaceTest.php
[edit]
[-] ExpandRulesetReferenceCaseMismatch2Test.xml
[edit]
[-] PopulateTokenListenersTest.php
[edit]
[-] ExpandSniffDirectoryTest.xml
[edit]
[-] ExpandRulesetReferenceInvalidErrorCode1Test.xml
[edit]
[-] SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml
[edit]
[-] ExpandRulesetReferenceTest.php
[edit]
[-] RegisterSniffsMissingInterfaceValidTest.xml
[edit]
[-] ExpandRulesetReferenceHomePathTest.php
[edit]
[-] ExpandRulesetReferenceUnknownCategoryTest.xml
[edit]
[-] ExpandSniffDirectoryTest.php
[edit]
[-] RuleInclusionAbsoluteWindowsTest.php
[edit]
[-] AbstractRulesetTestCase.php
[edit]
[-] ProcessRulesetTest.php
[edit]
[-] ShowSniffDeprecationsEmptyRemovalVersionTest.xml
[edit]
[-] GetIncludePatternsTest.xml
[edit]
[-] RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml
[edit]
[-] RegisterSniffsTest.php
[edit]
[+]
Fixtures
[-] SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml
[edit]
[-] ShowSniffDeprecationsTest.xml
[edit]
[-] ExpandRulesetReferenceMissingFileTest.xml
[edit]
[-] ProcessRulesetBrokenRulesetEmptyFileTest.xml
[edit]
[-] ExpandRulesetReferenceInternalIgnoreTest.xml
[edit]
[-] ExpandRulesetReferenceInternalTest.php
[edit]
[-] ProcessRulesetMiscTest.xml
[edit]
[-] SetPropertyAllowedViaStdClassTest.xml
[edit]
[-] PopulateTokenListenersRegisterNoArrayTest.xml
[edit]
[-] RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml
[edit]
[-] ExpandRulesetReferenceUnknownSniffTest.xml
[edit]
[-] ProcessRulesetBrokenRulesetSingleErrorTest.xml
[edit]
[-] ExpandRulesetReferenceCaseMismatch1Test.xml
[edit]
[-] SetPropertyNotAllowedViaAttributeTest.xml
[edit]
[-] GetIgnorePatternsTest.xml
[edit]
[-] RuleInclusionAbsoluteLinuxTest.xml
[edit]
[-] ShowSniffDeprecationsEmptyDeprecationVersionTest.xml
[edit]
[-] PopulateTokenListenersSupportedTokenizersTest.php
[edit]
[-] ShowSniffDeprecationsInvalidRemovalVersionTest.xml
[edit]
[-] ShowSniffDeprecationsTest.php
[edit]
[-] ProcessRuleInvalidTypeTest.php
[edit]
[-] RegisterSniffsRejectsInvalidSniffTest.php
[edit]
[-] SetPropertyAllowedAsDeclaredTest.xml
[edit]
[-] ShowSniffDeprecationsReportWidthTest.xml
[edit]
[-] ProcessRuleInvalidTypeTest.xml
[edit]
[-] ExpandRulesetReferenceInternalStandardTest.xml
[edit]
[-] ExpandRulesetReferenceInvalidErrorCode2Test.xml
[edit]
[-] PopulateTokenListenersNamingConventionsTest.xml
[edit]
[-] SetSniffPropertyTest.php
[edit]
[-] ProcessRuleShouldProcessElementTest.xml
[edit]
[-] RuleInclusionTest-include.xml
[edit]
[-] ShowSniffDeprecationsInvalidDeprecationMessageTest.xml
[edit]
[-] PopulateTokenListenersSupportedTokenizersTest.xml
[edit]
[-] RuleInclusionTest.xml
[edit]
[-] ProcessRulesetAutoloadFileNotFoundTest.xml
[edit]
[-] RuleInclusionTest.php
[edit]
[-] PopulateTokenListenersNamingConventionsTest.php
[edit]
[-] ExplainSingleSniffTest.xml
[edit]
[-] GetIncludePatternsTest.php
[edit]
[-] GetIgnorePatternsTest.php
[edit]
[-] RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml
[edit]
[-] ExpandRulesetReferenceHomePathFailTest.xml
[edit]
[-] ProcessRuleShouldProcessElementTest.php
[edit]
[-] ExpandRulesetReferenceUnknownStandardTest.xml
[edit]
[-] ExplainTest.php
[edit]
[-] PopulateTokenListenersTest.xml
[edit]
[-] ExpandRulesetReferenceHomePathTest.xml
[edit]
[-] ConstructorTest.php
[edit]
[-] PropertyTypeHandlingTest.php
[edit]
[-] ProcessRulesetAutoloadTest.php
[edit]
[-] PropertyTypeHandlingInlineTest.xml
[edit]
[-] SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml
[edit]
[-] RegisterSniffsMissingInterfaceInvalidTest.xml
[edit]
[-] ProcessRulesetAutoloadTest.xml
[edit]
[-] SetPropertyAllowedViaMagicMethodTest.xml
[edit]
[-] ProcessRulesetInvalidNoSniffsDirTest.xml
[edit]
[-] ShowSniffDeprecationsOrderTest.xml
[edit]
[-] ExpandRulesetReferenceInvalidErrorCode3Test.xml
[edit]
[-] RuleInclusionAbsoluteLinuxTest.php
[edit]
[-] SetPropertyThrowsErrorOnInvalidPropertyTest.xml
[edit]
[-] ProcessRulesetBrokenRulesetTest.php
[edit]
[-] ConstructorNoSniffsTest.xml
[edit]
[-] ExpandRulesetReferenceInvalidHomePathRefTest.xml
[edit]
[-] ExpandRulesetReferenceTest.xml
[edit]
[-] ProcessRulesetBrokenRulesetMultiErrorTest.xml
[edit]
[-] RuleInclusionAbsoluteWindowsTest.xml
[edit]
[-] ProcessRulesetShouldProcessElementTest.php
[edit]
[-] DisplayCachedMessagesTest.php
[edit]