Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Test handling of invalid type elements.
*
* @author Juliette Reinders Folmer <[email protected]>
* @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
9 changes: 9 additions & 0 deletions tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ProcessRuleInvalidTypeTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

<rule ref="Generic.Files.ByteOrderMark">
<!-- Invalid type will throw an error. -->
<type>notice</type>
</rule>

</ruleset>