diff --git a/PHP/CodeCoverage/Report/HTML.php b/PHP/CodeCoverage/Report/HTML.php
index c5898026e..f7aa153d3 100644
--- a/PHP/CodeCoverage/Report/HTML.php
+++ b/PHP/CodeCoverage/Report/HTML.php
@@ -106,6 +106,14 @@ public function __construct(array $options = array())
$options['generator'] = '';
}
+ if (!isset($options['methodCoverageThreshold'])) {
+ $options['methodCoverageThreshold'] = 100;
+ }
+
+ if (!isset($options['classCoverageThreshold'])) {
+ $options['classCoverageThreshold'] = 100;
+ }
+
$this->options = $options;
self::$templatePath = sprintf(
@@ -210,7 +218,10 @@ protected function addItems(PHP_CodeCoverage_Report_HTML_Node_Directory $root, a
substr($key, 0, -2),
$value,
$this->options['yui'],
- $this->options['highlight']
+ $this->options['highlight'],
+ $this->options['methodCoverageThreshold'],
+ $this->options['classCoverageThreshold']
+
);
}
diff --git a/PHP/CodeCoverage/Report/HTML/Node/Directory.php b/PHP/CodeCoverage/Report/HTML/Node/Directory.php
index 0cad206dd..eac0ffd4a 100644
--- a/PHP/CodeCoverage/Report/HTML/Node/Directory.php
+++ b/PHP/CodeCoverage/Report/HTML/Node/Directory.php
@@ -146,13 +146,15 @@ public function addDirectory($name)
* @param array $lines
* @param boolean $yui
* @param boolean $highlight
+ * @param string $methodCoverageThreshold
+ * @param string $classCoverageThreshold
* @return PHP_CodeCoverage_Report_HTML_Node_File
* @throws RuntimeException
*/
- public function addFile($name, array $lines, $yui, $highlight)
+ public function addFile($name, array $lines, $yui, $highlight, $methodCoverageThreshold, $classCoverageThreshold)
{
$file = new PHP_CodeCoverage_Report_HTML_Node_File(
- $name, $this, $lines, $yui, $highlight
+ $name, $this, $lines, $yui, $highlight, $methodCoverageThreshold, $classCoverageThreshold
);
$this->children[] = $file;
diff --git a/PHP/CodeCoverage/Report/HTML/Node/File.php b/PHP/CodeCoverage/Report/HTML/Node/File.php
index 3e44e7256..daeb4feb8 100644
--- a/PHP/CodeCoverage/Report/HTML/Node/File.php
+++ b/PHP/CodeCoverage/Report/HTML/Node/File.php
@@ -138,6 +138,16 @@ class PHP_CodeCoverage_Report_HTML_Node_File extends PHP_CodeCoverage_Report_HTM
*/
protected $endLines = array();
+ /**
+ * @var string
+ */
+ protected $methodCoverageThreshold;
+
+ /**
+ * @var string
+ */
+ protected $classCoverageThreshold;
+
/**
* Constructor.
*
@@ -146,9 +156,11 @@ class PHP_CodeCoverage_Report_HTML_Node_File extends PHP_CodeCoverage_Report_HTM
* @param array $executedLines
* @param boolean $yui
* @param boolean $highlight
+ * @param string $methodCoverageThreshold
+ * @param string $classCoverageThreshold
* @throws RuntimeException
*/
- public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, array $executedLines, $yui = TRUE, $highlight = FALSE)
+ public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, array $executedLines, $yui = TRUE, $highlight = FALSE, $methodCoverageThreshold = 100, $classCoverageThreshold = 100)
{
parent::__construct($name, $parent);
@@ -167,7 +179,9 @@ public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, ar
$this->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored(
$path
);
-
+ $this->methodCoverageThreshold = $methodCoverageThreshold;
+ $this->classCoverageThreshold = $classCoverageThreshold;
+
$this->calculateStatistics();
}
@@ -391,7 +405,7 @@ public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35,
$items = '';
foreach ($this->classes as $className => $classData) {
- if ($classData['executedLines'] == $classData['executableLines']) {
+ if ($classData['coverage'] >= $this->classCoverageThreshold) {
$numTestedClasses = 1;
$testedClassesPercent = 100;
} else {
@@ -403,7 +417,8 @@ public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35,
$numMethods = count($classData['methods']);
foreach ($classData['methods'] as $method) {
- if ($method['executedLines'] == $method['executableLines']) {
+
+ if ($method['coverage'] >= $this->methodCoverageThreshold) {
$numTestedMethods++;
}
}
@@ -439,8 +454,8 @@ public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35,
);
foreach ($classData['methods'] as $methodData) {
- if ($methodData['executedLines'] ==
- $methodData['executableLines']) {
+
+ if ($methodData['coverage'] >= $this->methodCoverageThreshold) {
$numTestedMethods = 1;
$testedMethodsPercent = 100;
} else {
@@ -595,7 +610,7 @@ protected function calculateStatistics()
$method['coverage'] = 100;
}
- if ($method['coverage'] == 100) {
+ if ($method['coverage'] >= $this->methodCoverageThreshold) {
$this->numTestedMethods++;
}
@@ -614,7 +629,7 @@ protected function calculateStatistics()
$class['coverage'] = 100;
}
- if ($class['coverage'] == 100) {
+ if ($class['coverage'] >= $this->classCoverageThreshold) {
$this->numTestedClasses++;
}