Skip to content

Commit 97fd6a5

Browse files
committed
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
1 parent 142199d commit 97fd6a5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/Standards/AbstractSniffTestCase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ final public function testSniff()
227227
$failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff";
228228
}
229229
}
230-
} else if (is_callable([$this, 'addWarning']) === true) {
231-
$this->addWarning("Missing fixed version of $filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file");
230+
} else {
231+
$diff = trim($phpcsFile->fixer->generateDiff($testFile));
232+
$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";
232233
}
233234
}//end if
234235

0 commit comments

Comments
 (0)