Skip to content

Commit 8f2ec28

Browse files
committed
ErrorSuppressionTest: move one test case out of testSuppressLine()
... as it uses a different code pattern, so doesn't fit with the other tests for the (upcoming) data provider.
1 parent 58e8734 commit 8f2ec28

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

tests/Core/ErrorSuppressionTest.php

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,6 @@ public function testSuppressLine()
424424
$this->assertEquals(1, $numErrors);
425425
$this->assertCount(1, $errors);
426426

427-
// Process with @ suppression on line before inside docblock.
428-
$content = '<?php '.PHP_EOL.'/**'.PHP_EOL.' * Comment here'.PHP_EOL.' * @phpcs:ignore'.PHP_EOL.' * '.str_repeat('a ', 50).PHP_EOL.'*/';
429-
$file = new DummyFile($content, $ruleset, $config);
430-
$file->process();
431-
432-
$errors = $file->getErrors();
433-
$numErrors = $file->getErrorCount();
434-
$this->assertEquals(0, $numErrors);
435-
$this->assertCount(0, $errors);
436-
437427
// Process with suppression on same line.
438428
$content = '<?php '.PHP_EOL.'$var = FALSE; // phpcs:ignore'.PHP_EOL.'$var = FALSE;';
439429
$file = new DummyFile($content, $ruleset, $config);
@@ -487,6 +477,40 @@ public function testSuppressLine()
487477
}//end testSuppressLine()
488478

489479

480+
/**
481+
* Test suppressing a single error using a single line ignore within a docblock.
482+
*
483+
* @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap
484+
*
485+
* @return void
486+
*/
487+
public function testSuppressLineWithinDocblock()
488+
{
489+
$config = new Config();
490+
$config->standards = ['Generic'];
491+
$config->sniffs = ['Generic.Files.LineLength'];
492+
493+
$ruleset = new Ruleset($config);
494+
495+
// Process with @ suppression on line before inside docblock.
496+
$comment = str_repeat('a ', 50);
497+
$content = <<<EOD
498+
<?php
499+
/**
500+
* Comment here
501+
* @phpcs:ignore
502+
* $comment
503+
*/
504+
EOD;
505+
$file = new DummyFile($content, $ruleset, $config);
506+
$file->process();
507+
508+
$this->assertSame(0, $file->getErrorCount());
509+
$this->assertCount(0, $file->getErrors());
510+
511+
}//end testSuppressLineWithinDocblock()
512+
513+
490514
/**
491515
* Test that using a single line ignore does not interfere with other suppressions.
492516
*

0 commit comments

Comments
 (0)