-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from PHPCSStandards/feature/ruleset-explain-r…
…efactor-and-add-tests Ruleset::explain(): refactor method to remove use of output buffers + add test
- Loading branch information
Showing
2 changed files
with
80 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Tests to verify that the "explain" command functions as expected. | ||
* | ||
* @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl> | ||
* @copyright 2023 Juliette Reinders Folmer. All rights reserved. | ||
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
*/ | ||
|
||
namespace PHP_CodeSniffer\Tests\Core\Ruleset; | ||
|
||
use PHP_CodeSniffer\Config; | ||
use PHP_CodeSniffer\Ruleset; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test the Ruleset::explain() function. | ||
* | ||
* @covers \PHP_CodeSniffer\Ruleset::explain | ||
*/ | ||
class ExplainTest extends TestCase | ||
{ | ||
|
||
|
||
/** | ||
* Test the output of the "explain" command. | ||
* | ||
* @return void | ||
*/ | ||
public function testExplain() | ||
{ | ||
// Set up the ruleset. | ||
$config = new Config(['--standard=PSR1', '-e']); | ||
$ruleset = new Ruleset($config); | ||
|
||
$expected = PHP_EOL; | ||
$expected .= 'The PSR1 standard contains 8 sniffs'.PHP_EOL.PHP_EOL; | ||
$expected .= 'Generic (4 sniffs)'.PHP_EOL; | ||
$expected .= '------------------'.PHP_EOL; | ||
$expected .= ' Generic.Files.ByteOrderMark'.PHP_EOL; | ||
$expected .= ' Generic.NamingConventions.UpperCaseConstantName'.PHP_EOL; | ||
$expected .= ' Generic.PHP.DisallowAlternativePHPTags'.PHP_EOL; | ||
$expected .= ' Generic.PHP.DisallowShortOpenTag'.PHP_EOL.PHP_EOL; | ||
$expected .= 'PSR1 (3 sniffs)'.PHP_EOL; | ||
$expected .= '---------------'.PHP_EOL; | ||
$expected .= ' PSR1.Classes.ClassDeclaration'.PHP_EOL; | ||
$expected .= ' PSR1.Files.SideEffects'.PHP_EOL; | ||
$expected .= ' PSR1.Methods.CamelCapsMethodName'.PHP_EOL.PHP_EOL; | ||
$expected .= 'Squiz (1 sniff)'.PHP_EOL; | ||
$expected .= '---------------'.PHP_EOL; | ||
$expected .= ' Squiz.Classes.ValidClassName'.PHP_EOL; | ||
|
||
$this->expectOutputString($expected); | ||
|
||
$ruleset->explain(); | ||
|
||
}//end testExplain() | ||
|
||
|
||
}//end class |