From fac9db058be601dd0e86761919721180ec1b6520 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 11 Mar 2020 22:32:47 +0100 Subject: [PATCH] AbstractSniffUnitTest: bug fix - warnings not counted in total At the bottom of a test run a message along the lines of `4 sniff test files generated 2 unique error codes; 0 were fixable (0%)` is shown. The unique error codes, as well as the fixable count and percentage would only include `error` codes and would totally disregard the codes coming from `warning`s. Fixed now. --- tests/Standards/AbstractSniffUnitTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Standards/AbstractSniffUnitTest.php b/tests/Standards/AbstractSniffUnitTest.php index dc7c14cbe8..c050a0c2af 100644 --- a/tests/Standards/AbstractSniffUnitTest.php +++ b/tests/Standards/AbstractSniffUnitTest.php @@ -320,6 +320,17 @@ public function generateFailureMessages(LocalFile $file) $warningsTemp = []; foreach ($warnings as $warning) { $warningsTemp[] = $warning['message'].' ('.$warning['source'].')'; + + $source = $warning['source']; + if (in_array($source, $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'], true) === false) { + $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'][] = $source; + } + + if ($warning['fixable'] === true + && in_array($source, $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'], true) === false + ) { + $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'][] = $source; + } } $allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp);