Skip to content

Commit 32ecc58

Browse files
committed
ErrorSuppressionTest: fix bug in testSuppressScope()
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.
1 parent f9dfb9b commit 32ecc58

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/Core/ErrorSuppressionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public function testSuppressScope()
579579
{
580580
$config = new Config();
581581
$config->standards = ['PEAR'];
582-
$config->sniffs = ['PEAR.NamingConventions.ValidVariableName'];
582+
$config->sniffs = ['PEAR.Functions.FunctionDeclaration'];
583583

584584
$ruleset = new Ruleset($config);
585585

@@ -590,8 +590,8 @@ public function testSuppressScope()
590590

591591
$errors = $file->getErrors();
592592
$numErrors = $file->getErrorCount();
593-
$this->assertEquals(0, $numErrors);
594-
$this->assertCount(0, $errors);
593+
$this->assertEquals(1, $numErrors);
594+
$this->assertCount(1, $errors);
595595

596596
// Process with suppression.
597597
$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.'}';

0 commit comments

Comments
 (0)