Skip to content

Commit 231a6ab

Browse files
committed
Add overall report
1 parent d8222de commit 231a6ab

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

src/Report/Text.php

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
8484
$report = $coverage->getReport();
8585

8686
$colors = [
87-
'header' => '',
88-
'classes' => '',
89-
'methods' => '',
90-
'lines' => '',
91-
'reset' => '',
92-
'eol' => '',
87+
'header' => '',
88+
'classes' => '',
89+
'methods' => '',
90+
'lines' => '',
91+
'branches' => '',
92+
'paths' => '',
93+
'reset' => '',
94+
'eol' => '',
9395
];
9496

9597
if ($showColors) {
@@ -108,13 +110,23 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
108110
$report->getNumExecutableLines()
109111
);
110112

113+
$colors['branches'] = $this->getCoverageColor(
114+
$report->getNumTestedBranches(),
115+
$report->getNumBranches()
116+
);
117+
118+
$colors['paths'] = $this->getCoverageColor(
119+
$report->getNumTestedPaths(),
120+
$report->getNumPaths()
121+
);
122+
111123
$colors['reset'] = self::COLOR_RESET;
112124
$colors['header'] = self::COLOR_HEADER;
113125
$colors['eol'] = self::COLOR_EOL;
114126
}
115127

116128
$classes = \sprintf(
117-
' Classes: %6s (%d/%d)',
129+
' Classes: %6s (%d/%d)',
118130
Util::percent(
119131
$report->getNumTestedClassesAndTraits(),
120132
$report->getNumClassesAndTraits(),
@@ -125,7 +137,7 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
125137
);
126138

127139
$methods = \sprintf(
128-
' Methods: %6s (%d/%d)',
140+
' Methods: %6s (%d/%d)',
129141
Util::percent(
130142
$report->getNumTestedMethods(),
131143
$report->getNumMethods(),
@@ -136,7 +148,7 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
136148
);
137149

138150
$lines = \sprintf(
139-
' Lines: %6s (%d/%d)',
151+
' Lines: %6s (%d/%d)',
140152
Util::percent(
141153
$report->getNumExecutedLines(),
142154
$report->getNumExecutableLines(),
@@ -146,6 +158,28 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
146158
$report->getNumExecutableLines()
147159
);
148160

161+
$branches = \sprintf(
162+
' Branches: %6s (%d/%d)',
163+
Util::percent(
164+
$report->getNumTestedBranches(),
165+
$report->getNumBranches(),
166+
true
167+
),
168+
$report->getNumTestedBranches(),
169+
$report->getNumBranches()
170+
);
171+
172+
$paths = \sprintf(
173+
' Paths: %6s (%d/%d)',
174+
Util::percent(
175+
$report->getNumTestedPaths(),
176+
$report->getNumPaths(),
177+
true
178+
),
179+
$report->getNumTestedPaths(),
180+
$report->getNumPaths()
181+
);
182+
149183
$padding = \max(\array_map('strlen', [$classes, $methods, $lines]));
150184

151185
if ($this->showOnlySummary) {
@@ -166,6 +200,8 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
166200
$output .= $this->format($colors['classes'], $padding, $classes);
167201
$output .= $this->format($colors['methods'], $padding, $methods);
168202
$output .= $this->format($colors['lines'], $padding, $lines);
203+
$output .= $this->format($colors['branches'], $padding, $branches);
204+
$output .= $this->format($colors['paths'], $padding, $paths);
169205

170206
if ($this->showOnlySummary) {
171207
return $output . \PHP_EOL;

0 commit comments

Comments
 (0)