From a91ae54155b4905d20055c8da433e527ede57c70 Mon Sep 17 00:00:00 2001 From: Alexander Kazakov Date: Sun, 4 Aug 2013 16:06:48 +0400 Subject: [PATCH] fix showing coverage data for classes in text report --- PHP/CodeCoverage/Report/Text.php | 49 ++++++-------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/PHP/CodeCoverage/Report/Text.php b/PHP/CodeCoverage/Report/Text.php index a545cb155..181a8318a 100644 --- a/PHP/CodeCoverage/Report/Text.php +++ b/PHP/CodeCoverage/Report/Text.php @@ -184,56 +184,23 @@ public function process(PHP_CodeCoverage $coverage, $showColors = FALSE) } $classes = $item->getClassesAndTraits(); - $coverage = $item->getCoverageData(); - $lines = array(); foreach ($classes as $className => $class) { $classStatements = 0; $coveredClassStatements = 0; $coveredMethods = 0; + $classMethods = 0; foreach ($class['methods'] as $method) { - $methodCount = 0; - $methodLines = 0; - $methodLinesCovered = 0; - - for ($i = $method['startLine']; - $i <= $method['endLine']; - $i++) { - $add = TRUE; - $count = 0; - - if (isset($coverage[$i])) { - if ($coverage[$i] !== NULL) { - $classStatements++; - $methodLines++; - } else { - $add = FALSE; - } - - $count = count($coverage[$i]); - - if ($count > 0) { - $coveredClassStatements++; - $methodLinesCovered++; - } - } else { - $add = FALSE; - } - - $methodCount = max($methodCount, $count); - - if ($add) { - $lines[$i] = array( - 'count' => $count, 'type' => 'stmt' - ); - } - } + if ($method['executableLines'] == 0) + continue; - if ($methodCount > 0) { + $classMethods++; + $classStatements += $method['executableLines']; + $coveredClassStatements += $method['executedLines']; + if ($method['coverage'] == 100){ $coveredMethods++; } - } if (!empty($class['package']['namespace'])) { @@ -252,7 +219,7 @@ public function process(PHP_CodeCoverage $coverage, $showColors = FALSE) 'namespace' => $namespace, 'className ' => $className, 'methodsCovered' => $coveredMethods, - 'methodCount' => count($class['methods']), + 'methodCount' => $classMethods, 'statementsCovered' => $coveredClassStatements, 'statementCount' => $classStatements, );