File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Test handling of invalid type elements.
4+ *
5+ * @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl>
6+ * @copyright 2024 PHPCSStandards and contributors
7+ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8+ */
9+
10+ namespace PHP_CodeSniffer \Tests \Core \Ruleset ;
11+
12+ use PHP_CodeSniffer \Ruleset ;
13+ use PHP_CodeSniffer \Tests \ConfigDouble ;
14+ use PHP_CodeSniffer \Tests \Core \Ruleset \AbstractRulesetTestCase ;
15+
16+ /**
17+ * Test handling of invalid type elements.
18+ *
19+ * @covers \PHP_CodeSniffer\Ruleset::processRule
20+ */
21+ final class ProcessRuleInvalidTypeTest extends AbstractRulesetTestCase
22+ {
23+
24+
25+ /**
26+ * Test displaying an informative error message when an invalid type is given.
27+ *
28+ * @return void
29+ */
30+ public function testInvalidTypeHandling ()
31+ {
32+ $ standard = __DIR__ .'/ProcessRuleInvalidTypeTest.xml ' ;
33+ $ config = new ConfigDouble (["--standard= $ standard " ]);
34+
35+ $ message = 'Message type "notice" is invalid; must be "error" or "warning" ' ;
36+ $ this ->expectRuntimeExceptionMessage ($ message );
37+
38+ new Ruleset ($ config );
39+
40+ }//end testInvalidTypeHandling()
41+
42+
43+ }//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 =" ProcessRuleInvalidTypeTest" xsi : noNamespaceSchemaLocation =" https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd" >
3+
4+ <rule ref =" Generic.Files.ByteOrderMark" >
5+ <!-- Invalid type will throw an error. -->
6+ <type >notice</type >
7+ </rule >
8+
9+ </ruleset >
You can’t perform that action at this time.
0 commit comments