@@ -138,6 +138,16 @@ class PHP_CodeCoverage_Report_HTML_Node_File extends PHP_CodeCoverage_Report_HTM
138
138
*/
139
139
protected $ endLines = array ();
140
140
141
+ /**
142
+ * @var string
143
+ */
144
+ protected $ methodCoverageThreshold ;
145
+
146
+ /**
147
+ * @var string
148
+ */
149
+ protected $ classCoverageThreshold ;
150
+
141
151
/**
142
152
* Constructor.
143
153
*
@@ -146,9 +156,11 @@ class PHP_CodeCoverage_Report_HTML_Node_File extends PHP_CodeCoverage_Report_HTM
146
156
* @param array $executedLines
147
157
* @param boolean $yui
148
158
* @param boolean $highlight
159
+ * @param string $methodCoverageThreshold
160
+ * @param string $classCoverageThreshold
149
161
* @throws RuntimeException
150
162
*/
151
- public function __construct ($ name , PHP_CodeCoverage_Report_HTML_Node $ parent , array $ executedLines , $ yui = TRUE , $ highlight = FALSE )
163
+ public function __construct ($ name , PHP_CodeCoverage_Report_HTML_Node $ parent , array $ executedLines , $ yui = TRUE , $ highlight = FALSE , $ methodCoverageThreshold = 100 , $ classCoverageThreshold = 100 )
152
164
{
153
165
parent ::__construct ($ name , $ parent );
154
166
@@ -167,7 +179,9 @@ public function __construct($name, PHP_CodeCoverage_Report_HTML_Node $parent, ar
167
179
$ this ->ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored (
168
180
$ path
169
181
);
170
-
182
+ $ this ->methodCoverageThreshold = $ methodCoverageThreshold ;
183
+ $ this ->classCoverageThreshold = $ classCoverageThreshold ;
184
+
171
185
$ this ->calculateStatistics ();
172
186
}
173
187
@@ -391,7 +405,7 @@ public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35,
391
405
$ items = '' ;
392
406
393
407
foreach ($ this ->classes as $ className => $ classData ) {
394
- if ($ classData ['executedLines ' ] == $ classData [ ' executableLines ' ] ) {
408
+ if ($ classData ['coverage ' ] >= $ this -> classCoverageThreshold ) {
395
409
$ numTestedClasses = 1 ;
396
410
$ testedClassesPercent = 100 ;
397
411
} else {
@@ -403,7 +417,8 @@ public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35,
403
417
$ numMethods = count ($ classData ['methods ' ]);
404
418
405
419
foreach ($ classData ['methods ' ] as $ method ) {
406
- if ($ method ['executedLines ' ] == $ method ['executableLines ' ]) {
420
+
421
+ if ($ method ['coverage ' ] >= $ this ->methodCoverageThreshold ) {
407
422
$ numTestedMethods ++;
408
423
}
409
424
}
@@ -439,8 +454,8 @@ public function render($target, $title, $charset = 'UTF-8', $lowUpperBound = 35,
439
454
);
440
455
441
456
foreach ($ classData ['methods ' ] as $ methodData ) {
442
- if ( $ methodData [ ' executedLines ' ] ==
443
- $ methodData ['executableLines ' ] ) {
457
+
458
+ if ( $ methodData ['coverage ' ] >= $ this -> methodCoverageThreshold ) {
444
459
$ numTestedMethods = 1 ;
445
460
$ testedMethodsPercent = 100 ;
446
461
} else {
@@ -595,7 +610,7 @@ protected function calculateStatistics()
595
610
$ method ['coverage ' ] = 100 ;
596
611
}
597
612
598
- if ($ method ['coverage ' ] == 100 ) {
613
+ if ($ method ['coverage ' ] >= $ this -> methodCoverageThreshold ) {
599
614
$ this ->numTestedMethods ++;
600
615
}
601
616
@@ -614,7 +629,7 @@ protected function calculateStatistics()
614
629
$ class ['coverage ' ] = 100 ;
615
630
}
616
631
617
- if ($ class ['coverage ' ] == 100 ) {
632
+ if ($ class ['coverage ' ] >= $ this -> classCoverageThreshold ) {
618
633
$ this ->numTestedClasses ++;
619
634
}
620
635
0 commit comments