From 97fd6a5333e126a7f520031d5b3438d911263bdf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 23 Jan 2024 02:43:19 +0100 Subject: [PATCH] AbstractSniffTestCase: flag missing `.fixed` files As per issue 300, the PHPCS native `AbstractSniffUnitTest` test case should flag sniff test case files which would lead to fixes, but for which no `.fixed` file is available to verify the fixes against. It should also fail a test run when this occurs. This commit makes it so. Fixes 300 --- tests/Standards/AbstractSniffTestCase.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Standards/AbstractSniffTestCase.php b/tests/Standards/AbstractSniffTestCase.php index 56c4bd9d54..a481ca9b3f 100644 --- a/tests/Standards/AbstractSniffTestCase.php +++ b/tests/Standards/AbstractSniffTestCase.php @@ -227,8 +227,9 @@ final public function testSniff() $failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff"; } } - } else if (is_callable([$this, 'addWarning']) === true) { - $this->addWarning("Missing fixed version of $filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file"); + } else { + $diff = trim($phpcsFile->fixer->generateDiff($testFile)); + $failureMessages[] = "Missing fixed version of $filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file; the diff is\n$diff"; } }//end if