From 6f8869631f7ffbbb8d5e39461c0b6ac684bfe5ce Mon Sep 17 00:00:00 2001 From: "Mark Story mark@mark-story.com" Date: Thu, 1 Sep 2011 20:33:09 +0100 Subject: [PATCH] Fixing issue where divide by 0 errors would crop up on empty files. --- lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php index eb8d4d753..5cc24a5d2 100644 --- a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php +++ b/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();