Skip to content

Commit c14b49d

Browse files
committed
ErrorSuppressionTest: add test for midline ignore
1 parent d465698 commit c14b49d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/Core/ErrorSuppressionTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,31 @@ public function dataSuppressLine()
422422
}//end dataSuppressLine()
423423

424424

425+
/**
426+
* Test suppressing a single error using a single line ignore in the middle of a line.
427+
*
428+
* @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap
429+
*
430+
* @return void
431+
*/
432+
public function testSuppressLineMidLine()
433+
{
434+
$config = new Config();
435+
$config->standards = ['Generic'];
436+
$config->sniffs = ['Generic.PHP.LowerCaseConstant'];
437+
438+
$ruleset = new Ruleset($config);
439+
440+
$content = '<?php '.PHP_EOL.'$var = FALSE; /* @phpcs:ignore */ $var = FALSE;';
441+
$file = new DummyFile($content, $ruleset, $config);
442+
$file->process();
443+
444+
$this->assertSame(0, $file->getErrorCount());
445+
$this->assertCount(0, $file->getErrors());
446+
447+
}//end testSuppressLineMidLine()
448+
449+
425450
/**
426451
* Test suppressing a single error using a single line ignore within a docblock.
427452
*

0 commit comments

Comments
 (0)