Skip to content

Commit

Permalink
ErrorSuppressionTest: fix bug in testSuppressScope()
Browse files Browse the repository at this point in the history
As the "no suppression" test would yield no errors, the test wasn't actually testing anything as there were no errors to suppress.

Fixed now by using a different sniff to test against, which does yield an error on the line being suppressed by the rest of the tests.
  • Loading branch information
jrfnl committed May 8, 2021
1 parent f9dfb9b commit 32ecc58
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/Core/ErrorSuppressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function testSuppressScope()
{
$config = new Config();
$config->standards = ['PEAR'];
$config->sniffs = ['PEAR.NamingConventions.ValidVariableName'];
$config->sniffs = ['PEAR.Functions.FunctionDeclaration'];

$ruleset = new Ruleset($config);

Expand All @@ -590,8 +590,8 @@ public function testSuppressScope()

$errors = $file->getErrors();
$numErrors = $file->getErrorCount();
$this->assertEquals(0, $numErrors);
$this->assertCount(0, $errors);
$this->assertEquals(1, $numErrors);
$this->assertCount(1, $errors);

// Process with suppression.
$content = '<?php '.PHP_EOL.'class MyClass() {'.PHP_EOL.'//phpcs:disable'.PHP_EOL.'function myFunction() {'.PHP_EOL.'//phpcs:enable'.PHP_EOL.'$this->foo();'.PHP_EOL.'}'.PHP_EOL.'}';
Expand Down

0 comments on commit 32ecc58

Please sign in to comment.