diff --git a/src/Result.php b/src/Result.php index 9b3a83e5..98e9e8b6 100644 --- a/src/Result.php +++ b/src/Result.php @@ -40,9 +40,20 @@ final class Result */ public static function exitCode(Configuration $configuration, TestResult $result): int { - if ($result->wasSuccessfulIgnoringPhpunitWarnings() - && ! $result->hasTestTriggeredPhpunitWarningEvents()) { - return self::SUCCESS_EXIT; + if ($result->wasSuccessfulIgnoringPhpunitWarnings()) { + if ($configuration->failOnWarning()) { + $warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents() + + count($result->warnings()) + + count($result->phpWarnings()); + + if ($warnings > 0) { + return self::FAILURE_EXIT; + } + } + + if (! $result->hasTestTriggeredPhpunitWarningEvents()) { + return self::SUCCESS_EXIT; + } } if ($configuration->failOnEmptyTestSuite() && ResultReflection::numberOfTests($result) === 0) { @@ -54,14 +65,6 @@ final class Result $returnCode = self::FAILURE_EXIT; } - $warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents() - + count($result->warnings()) - + count($result->phpWarnings()); - - if ($configuration->failOnWarning() && $warnings > 0) { - $returnCode = self::FAILURE_EXIT; - } - if ($configuration->failOnIncomplete() && $result->hasTestMarkedIncompleteEvents()) { $returnCode = self::FAILURE_EXIT; }