Browse Source

Fixing issue where divide by 0 errors would crop up on empty files.

Mark Story mark@mark-story.com 14 years ago
parent
commit
6f8869631f
1 changed files with 4 additions and 1 deletions
  1. 4 1
      lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php

+ 4 - 1
lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php

@@ -84,7 +84,10 @@ HTML;
 			$diff[] = $this->_paintLine($line, $lineno, $class, $coveringTests);
 			$diff[] = $this->_paintLine($line, $lineno, $class, $coveringTests);
 		}
 		}
 
 
-		$percentCovered = round(100 * $covered / $total, 2);
+		$percentCovered = 100;
+		if ($total > 0) {
+			$percentCovered = round(100 * $covered / $total, 2);
+		}
 		$output .= $this->coverageHeader($filename, $percentCovered);
 		$output .= $this->coverageHeader($filename, $percentCovered);
 		$output .= implode("", $diff);
 		$output .= implode("", $diff);
 		$output .= $this->coverageFooter();
 		$output .= $this->coverageFooter();