File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Test handling of the <include-pattern> element.
4+ *
5+ * @copyright 2024 PHPCSStandards and contributors
6+ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
7+ */
8+
9+ namespace PHP_CodeSniffer \Tests \Core \Ruleset ;
10+
11+ use PHP_CodeSniffer \Ruleset ;
12+ use PHP_CodeSniffer \Tests \ConfigDouble ;
13+
14+ /**
15+ * Test handling of the <include-pattern> element.
16+ *
17+ * @covers \PHP_CodeSniffer\Ruleset::processRule
18+ */
19+ final class ProcessRuleIncludePatternTest extends AbstractRulesetTestCase
20+ {
21+
22+ /**
23+ * The Ruleset object.
24+ *
25+ * @var \PHP_CodeSniffer\Ruleset
26+ */
27+ private static $ ruleset ;
28+
29+
30+ /**
31+ * Initialize the config and ruleset objects for this test.
32+ *
33+ * @before
34+ *
35+ * @return void
36+ */
37+ protected function initializeConfigAndRuleset ()
38+ {
39+ if (isset (self ::$ ruleset ) === false ) {
40+ // Set up the ruleset.
41+ $ standard = __DIR__ .'/ProcessRuleIncludePatternTest.xml ' ;
42+ $ config = new ConfigDouble (["--standard= $ standard " ]);
43+ self ::$ ruleset = new Ruleset ($ config );
44+ }
45+
46+ }//end initializeConfigAndRuleset()
47+
48+
49+ /**
50+ * Verify that <include-patterns> are set.
51+ *
52+ * @return void
53+ */
54+ public function testProcessRuleShouldSetIncludePatterns ()
55+ {
56+ $ expectedPatterns = [];
57+ $ this ->assertSame ($ expectedPatterns , self ::$ ruleset ->includePatterns );
58+
59+ }//end testProcessRuleShouldSetIncludePatterns()
60+
61+
62+ }//end class
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <ruleset xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" name =" ProcessRuleIncludePatternTest" xsi : noNamespaceSchemaLocation =" https://schema.phpcodesniffer.com/phpcs.xsd" >
3+ <rule ref =" Generic.Files.ByteOrderMark" >
4+ <include-pattern >./path/</include-pattern >
5+ <include-pattern type =" absolute" >/absolute/path/</include-pattern >
6+ <include-pattern type =" relative" >relative/path/</include-pattern >
7+ <include-pattern type =" invalidType" >invalid/type/</include-pattern >
8+ </rule >
9+
10+ </ruleset >
You can’t perform that action at this time.
0 commit comments