Skip to content

Commit 011aaea

Browse files
committed
WIP
Started creating some basic tests for the <include-pattern> element and then run into some questions. Posted then in the link below and waiting for answers: PHPCSStandards#727 (comment)
1 parent 368817d commit 011aaea

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>

0 commit comments

Comments
 (0)