From dbc16631e25cd7ee35f0757ddc8c211d80d1bbfd Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 14 Nov 2024 08:52:18 -0300 Subject: [PATCH] Generic/CyclomaticComplexity: rename test case file Doing this to be able to create tests with syntax errors on separate files. --- ...inc => CyclomaticComplexityUnitTest.1.inc} | 0 .../Metrics/CyclomaticComplexityUnitTest.php | 42 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) rename src/Standards/Generic/Tests/Metrics/{CyclomaticComplexityUnitTest.inc => CyclomaticComplexityUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc rename to src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php index 950ba3eec3..f7c75f79ca 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php @@ -26,11 +26,18 @@ final class CyclomaticComplexityUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [118 => 1]; + switch ($testFile) { + case 'CyclomaticComplexityUnitTest.1.inc': + return [118 => 1]; + default: + return []; + } }//end getErrorList() @@ -41,21 +48,28 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 45 => 1, - 72 => 1, - 189 => 1, - 237 => 1, - 285 => 1, - 333 => 1, - 381 => 1, - 417 => 1, - 445 => 1, - ]; + switch ($testFile) { + case 'CyclomaticComplexityUnitTest.1.inc': + return [ + 45 => 1, + 72 => 1, + 189 => 1, + 237 => 1, + 285 => 1, + 333 => 1, + 381 => 1, + 417 => 1, + 445 => 1, + ]; + default: + return []; + } }//end getWarningList()