Skip to content

Commit 482cb3f

Browse files
committed
Text report
1 parent befd680 commit 482cb3f

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/CodeCoverage/Report/Text.php

+26
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
5555
'classes' => '',
5656
'methods' => '',
5757
'lines' => '',
58+
'paths' => '',
5859
'reset' => '',
5960
'eol' => ''
6061
];
@@ -72,6 +73,10 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
7273
$report->getNumExecutedLines(),
7374
$report->getNumExecutableLines()
7475
);
76+
$colors['paths'] = $this->getCoverageColor(
77+
$report->getNumExecutedPaths(),
78+
$report->getNumExecutablePaths()
79+
);
7580
$colors['reset'] = $this->colors['reset'];
7681
$colors['header'] = $this->colors['header'];
7782
$colors['eol'] = $this->colors['eol'];
@@ -110,6 +115,17 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
110115
$report->getNumExecutableLines()
111116
);
112117

118+
$paths = sprintf(
119+
' Paths: %6s (%d/%d)',
120+
PHP_CodeCoverage_Util::percent(
121+
$report->getNumExecutedPaths(),
122+
$report->getNumExecutablePaths(),
123+
true
124+
),
125+
$report->getNumExecutedPaths(),
126+
$report->getNumExecutablePaths()
127+
);
128+
113129
$padding = max(array_map('strlen', [$classes, $methods, $lines]));
114130

115131
if ($this->showOnlySummary) {
@@ -130,6 +146,7 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
130146
$output .= $this->format($colors['classes'], $padding, $classes);
131147
$output .= $this->format($colors['methods'], $padding, $methods);
132148
$output .= $this->format($colors['lines'], $padding, $lines);
149+
$output .= $this->format($colors['paths'], $padding, $paths);
133150

134151
if ($this->showOnlySummary) {
135152
return $output . PHP_EOL;
@@ -147,6 +164,8 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
147164
foreach ($classes as $className => $class) {
148165
$classStatements = 0;
149166
$coveredClassStatements = 0;
167+
$classPaths = 0;
168+
$coveredClassPaths = 0;
150169
$coveredMethods = 0;
151170
$classMethods = 0;
152171

@@ -158,6 +177,8 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
158177
$classMethods++;
159178
$classStatements += $method['executableLines'];
160179
$coveredClassStatements += $method['executedLines'];
180+
$classPaths += $method['executablePaths'];
181+
$coveredClassPaths += $method['executedPaths'];
161182
if ($method['coverage'] == 100) {
162183
$coveredMethods++;
163184
}
@@ -178,6 +199,8 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
178199
'methodCount' => $classMethods,
179200
'statementsCovered' => $coveredClassStatements,
180201
'statementCount' => $classStatements,
202+
'pathsCovered' => $coveredClassPaths,
203+
'pathCount' => $classPaths,
181204
];
182205
}
183206
}
@@ -186,6 +209,7 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
186209

187210
$methodColor = '';
188211
$linesColor = '';
212+
$pathsColor = '';
189213
$resetColor = '';
190214

191215
foreach ($classCoverage as $fullQualifiedPath => $classInfo) {
@@ -194,12 +218,14 @@ public function process(PHP_CodeCoverage $coverage, $showColors = false)
194218
if ($showColors) {
195219
$methodColor = $this->getCoverageColor($classInfo['methodsCovered'], $classInfo['methodCount']);
196220
$linesColor = $this->getCoverageColor($classInfo['statementsCovered'], $classInfo['statementCount']);
221+
$pathsColor = $this->getCoverageColor($classInfo['pathsCovered'], $classInfo['pathCount']);
197222
$resetColor = $colors['reset'];
198223
}
199224

200225
$output .= PHP_EOL . $fullQualifiedPath . PHP_EOL
201226
. ' ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' '
202227
. ' ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor
228+
. ' ' . $pathsColor . ' Paths: ' . $this->printCoverageCounts($classInfo['pathsCovered'], $classInfo['pathCount'], 2) . $resetColor
203229
;
204230
}
205231
}

tests/_files/BankAccount-text.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Code Coverage Report:
77
Classes: 0.00% (0/1)
88
Methods: 75.00% (3/4)
99
Lines: 50.00% (5/10)
10+
Paths: 20.00% (1/5)
1011

1112
BankAccount
12-
Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10)
13+
Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10) Paths: 20.00% ( 1/ 5)

tests/_files/class-with-anonymous-function-text.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Code Coverage Report:
77
Classes: 0.00% (0/1)
88
Methods: 50.00% (1/2)
99
Lines: 87.50% (7/8)
10+
Paths: 0.00% (0/1)
1011

1112
CoveredClassWithAnonymousFunctionInStaticMethod
12-
Methods: 50.00% ( 1/ 2) Lines: 80.00% ( 4/ 5)
13+
Methods: 50.00% ( 1/ 2) Lines: 80.00% ( 4/ 5) Paths: 0.00% ( 0/ 1)

tests/_files/ignored-lines-text.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Code Coverage Report:
77
Classes: 100.00% (2/2)
88
Methods: (0/0)
99
Lines: 50.00% (1/2)
10+
Paths: 0.00% (0/3)
1011

0 commit comments

Comments
 (0)