ソースを参照

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

Mark Story mark@mark-story.com 14 年 前
コミット
6f8869631f
1 ファイル変更4 行追加1 行削除
  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);
 		}
 
-		$percentCovered = round(100 * $covered / $total, 2);
+		$percentCovered = 100;
+		if ($total > 0) {
+			$percentCovered = round(100 * $covered / $total, 2);
+		}
 		$output .= $this->coverageHeader($filename, $percentCovered);
 		$output .= implode("", $diff);
 		$output .= $this->coverageFooter();