Skip to content

Commit ce8f782

Browse files
authored
Merge pull request #1376 from PHPCSStandards/feature/1372-exitcode-add-extra-tests
ExitCodeTest: add extra tests
2 parents 0addd30 + 7b9452c commit ce8f782

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/Core/Util/ExitCode/ExitCodeTest.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,29 @@ public static function dataPhpcs()
230230
'expected' => 3,
231231
],
232232

233+
// Verify that when warnings or errors are suppressed, they don't affect the exit code.
234+
'Only warnings, while ignoring warnings' => [
235+
'extraArgs' => [
236+
'-n',
237+
'--sniffs=TestStandard.ExitCodes.Warning,TestStandard.ExitCodes.FixableWarning',
238+
],
239+
'expected' => 0,
240+
],
241+
'Only warnings, while warnings have severity 0' => [
242+
'extraArgs' => [
243+
'--warning-severity=0',
244+
'--sniffs=TestStandard.ExitCodes.Warning,TestStandard.ExitCodes.FixableWarning',
245+
],
246+
'expected' => 0,
247+
],
248+
'Only errors, while errors have severity 0' => [
249+
'extraArgs' => [
250+
'--error-severity=0',
251+
'--sniffs=TestStandard.ExitCodes.Error,TestStandard.ExitCodes.FixableError',
252+
],
253+
'expected' => 0,
254+
],
255+
233256
// In both the below cases, we still have 1 fixable and 1 non-fixable issue which we need to take into account, so exit code = 3.
234257
'Mix of errors and warnings, ignoring warnings for exit code' => [
235258
'extraArgs' => [
@@ -491,6 +514,50 @@ public static function dataPhpcbf()
491514
'expected' => 2,
492515
],
493516

517+
// Verify that when warnings or errors are suppressed, they don't affect the exit code.
518+
'Only warnings, while ignoring warnings' => [
519+
'extraArgs' => [
520+
'-n',
521+
'--sniffs=TestStandard.ExitCodes.Warning,TestStandard.ExitCodes.FixableWarning',
522+
],
523+
'expected' => 0,
524+
],
525+
'Only warnings, while warnings have severity 0' => [
526+
'extraArgs' => [
527+
'--warning-severity=0',
528+
'--sniffs=TestStandard.ExitCodes.Warning,TestStandard.ExitCodes.FixableWarning',
529+
],
530+
'expected' => 0,
531+
],
532+
'Only errors, while errors have severity 0' => [
533+
'extraArgs' => [
534+
'--error-severity=0',
535+
'--sniffs=TestStandard.ExitCodes.Error,TestStandard.ExitCodes.FixableError',
536+
],
537+
'expected' => 0,
538+
],
539+
'Fixed all auto-fixable errors, non-auto-fixable warnings remain, but are ignored' => [
540+
'extraArgs' => [
541+
'-n',
542+
'--sniffs=TestStandard.ExitCodes.FixableError,TestStandard.ExitCodes.Warning',
543+
],
544+
'expected' => 0,
545+
],
546+
'Fixed all auto-fixable errors, non-auto-fixable warnings remain, but warnings have severity 0' => [
547+
'extraArgs' => [
548+
'--warning-severity=0',
549+
'--sniffs=TestStandard.ExitCodes.FixableError,TestStandard.ExitCodes.Warning',
550+
],
551+
'expected' => 0,
552+
],
553+
'Fixed all auto-fixable warnings, non-auto-fixable errors remain, but errors have severity 0' => [
554+
'extraArgs' => [
555+
'--error-severity=0',
556+
'--sniffs=TestStandard.ExitCodes.FixableWarning,TestStandard.ExitCodes.Error',
557+
],
558+
'expected' => 0,
559+
],
560+
494561
// In both the below cases, we still have 1 non-fixable issue which we need to take into account, so exit code = 2.
495562
'Mix of errors and warnings, ignoring warnings for exit code' => [
496563
'extraArgs' => [

0 commit comments

Comments
 (0)