Skip to content

Commit

Permalink
ErrorSuppressionTest: prevent Internal errors
Browse files Browse the repository at this point in the history
... about a mismatch in line endings when the code "template" is defined using a heredoc with Linux line endings, while the code snippets being inserted into the code "template" were using line endings matching the OS on which the tests were being run.
  • Loading branch information
jrfnl committed Oct 31, 2023
1 parent 321d252 commit 7126fad
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/Core/ErrorSuppressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,19 +550,19 @@ public function dataNestedSuppressLine()

// Process with line suppression nested within disable/enable suppression.
'disable/enable: slash comment, next line nested single line suppression' => [
'before' => '// phpcs:disable'.PHP_EOL.'// phpcs:ignore',
'before' => '// phpcs:disable'."\n".'// phpcs:ignore',
'after' => '// phpcs:enable',
],
'disable/enable: slash comment, with @, next line nested single line suppression' => [
'before' => '// @phpcs:disable'.PHP_EOL.'// @phpcs:ignore',
'before' => '// @phpcs:disable'."\n".'// @phpcs:ignore',
'after' => '// @phpcs:enable',
],
'disable/enable: hash comment, next line nested single line suppression' => [
'before' => '# @phpcs:disable'.PHP_EOL.'# @phpcs:ignore',
'before' => '# @phpcs:disable'."\n".'# @phpcs:ignore',
'after' => '# @phpcs:enable',
],
'old style: slash comment, next line nested single line suppression' => [
'before' => '// @codingStandardsIgnoreStart'.PHP_EOL.'// @codingStandardsIgnoreLine',
'before' => '// @codingStandardsIgnoreStart'."\n".'// @codingStandardsIgnoreLine',
'after' => '// @codingStandardsIgnoreEnd',
],
];
Expand Down Expand Up @@ -734,7 +734,7 @@ public function dataSuppressFile()
'ignoreFile: start of file, hash comment, with @' => ['before' => '# @phpcs:ignoreFile'],
'ignoreFile: start of file, single-line star comment' => ['before' => '/* phpcs:ignoreFile */'],
'ignoreFile: start of file, multi-line star comment' => [
'before' => '/*'.PHP_EOL.' phpcs:ignoreFile'.PHP_EOL.' */',
'before' => '/*'."\n".' phpcs:ignoreFile'."\n".' */',
],
'ignoreFile: start of file, single-line docblock comment' => ['before' => '/** phpcs:ignoreFile */'],

Expand All @@ -748,7 +748,7 @@ public function dataSuppressFile()
'old style: start of file, slash comment' => ['before' => '// @codingStandardsIgnoreFile'],
'old style: start of file, single-line star comment' => ['before' => '/* @codingStandardsIgnoreFile */'],
'old style: start of file, multi-line star comment' => [
'before' => '/*'.PHP_EOL.' @codingStandardsIgnoreFile'.PHP_EOL.' */',
'before' => '/*'."\n".' @codingStandardsIgnoreFile'."\n".' */',
],
'old style: start of file, single-line docblock comment' => ['before' => '/** @codingStandardsIgnoreFile */'],

Expand Down Expand Up @@ -829,18 +829,18 @@ public function dataDisableSelected()
'expectedErrors' => 1,
],
'disable: single sniff, docblock' => [
'before' => '/**'.PHP_EOL.' * phpcs:disable Generic.Commenting.Todo'.PHP_EOL.' */ ',
'before' => '/**'."\n".' * phpcs:disable Generic.Commenting.Todo'."\n".' */ ',
'expectedErrors' => 1,
],
'disable: single sniff, docblock, with @' => [
'before' => '/**'.PHP_EOL.' * @phpcs:disable Generic.Commenting.Todo'.PHP_EOL.' */ ',
'before' => '/**'."\n".' * @phpcs:disable Generic.Commenting.Todo'."\n".' */ ',
'expectedErrors' => 1,
],

// Multiple sniffs.
'disable: multiple sniffs in one comment' => ['before' => '// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'],
'disable: multiple sniff in multiple comments' => [
'before' => '// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:disable Generic.PHP.LowerCaseConstant',
'before' => '// phpcs:disable Generic.Commenting.Todo'."\n".'// phpcs:disable Generic.PHP.LowerCaseConstant',
],

// Selectiveness variations.
Expand All @@ -857,17 +857,17 @@ public function dataDisableSelected()

// Wrong category/sniff/code.
'disable: wrong error code and category' => [
'before' => '/**'.PHP_EOL.' * phpcs:disable Generic.PHP.LowerCaseConstant.Upper,Generic.Comments'.PHP_EOL.' */ ',
'before' => '/**'."\n".' * phpcs:disable Generic.PHP.LowerCaseConstant.Upper,Generic.Comments'."\n".' */ ',
'expectedErrors' => 1,
'expectedWarnings' => 1,
],
'disable: wrong category, docblock' => [
'before' => '/**'.PHP_EOL.' * phpcs:disable Generic.Files'.PHP_EOL.' */ ',
'before' => '/**'."\n".' * phpcs:disable Generic.Files'."\n".' */ ',
'expectedErrors' => 1,
'expectedWarnings' => 1,
],
'disable: wrong category, docblock, with @' => [
'before' => '/**'.PHP_EOL.' * @phpcs:disable Generic.Files'.PHP_EOL.' */ ',
'before' => '/**'."\n".' * @phpcs:disable Generic.Files'."\n".' */ ',
'expectedErrors' => 1,
'expectedWarnings' => 1,
],
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public function dataIgnoreSelected()
'expectedWarnings' => 1,
],
'disable: single sniff; ignore: single sniff' => [
'before' => '// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:ignore Generic.PHP.LowerCaseConstant',
'before' => '// phpcs:disable Generic.Commenting.Todo'."\n".'// phpcs:ignore Generic.PHP.LowerCaseConstant',
'expectedErrors' => 1,
'expectedWarnings' => 0,
],
Expand Down

0 comments on commit 7126fad

Please sign in to comment.