diff --git a/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php new file mode 100644 index 0000000000..08a2e6b822 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php @@ -0,0 +1,43 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @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 PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test handling of invalid type elements. + * + * @covers \PHP_CodeSniffer\Ruleset::processRule + */ +final class ProcessRuleInvalidTypeTest extends AbstractRulesetTestCase +{ + + + /** + * Test displaying an informative error message when an invalid type is given. + * + * @return void + */ + public function testInvalidTypeHandling() + { + $standard = __DIR__.'/ProcessRuleInvalidTypeTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $message = 'Message type "notice" is invalid; must be "error" or "warning"'; + $this->expectRuntimeExceptionMessage($message); + + new Ruleset($config); + + }//end testInvalidTypeHandling() + + +}//end class diff --git a/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml new file mode 100644 index 0000000000..63c2aaf3c8 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml @@ -0,0 +1,9 @@ + + + + + + notice + + +