|
19 | 19 | use PHPUnit\Event\Test\Skipped; |
20 | 20 | use PHPUnit\Event\TestRunner\ExecutionStarted; |
21 | 21 | use PHPUnit\Event\Tracer\Tracer; |
22 | | -use PHPUnit\Util\Color; |
23 | 22 |
|
24 | 23 | final class Printer implements Tracer |
25 | 24 | { |
@@ -122,61 +121,25 @@ public function trace(Event $event): void |
122 | 121 | $id .= $data; |
123 | 122 | } |
124 | 123 |
|
125 | | - $ms = round($event->telemetryInfo()->time()->duration($this->start)->asFloat() * 1_000); |
| 124 | + $ms = round($event->telemetryInfo()->time()->duration($this->start)->asFloat() * 1_000)|0; |
126 | 125 | foreach ($this->performanceThresholds as $colour => $threshold) { |
127 | 126 | if ($ms >= $threshold) { |
128 | 127 | break; |
129 | 128 | } |
130 | 129 | } |
131 | 130 |
|
132 | | - printf( |
133 | | - "%3d%% %s %s %s%s", |
134 | | - floor(++$this->testCounter / $this->totalTests * 100), |
135 | | - $this->status->getStatusColour() === '' |
136 | | - ? $this->status->getStatusCode() |
137 | | - : Color::colorize("fg-{$this->status->getStatusColour()}", $this->status->getStatusCode()), |
138 | | - Color::colorize("fg-{$this->status->getColour()}", $id), |
139 | | - Color::colorize("fg-$colour", "($ms ms)"), |
140 | | - PHP_EOL, |
141 | | - ); |
142 | | - |
143 | | - if ($this->status === TestStatus::Failed) { |
144 | | - echo PHP_EOL, Color::colorize('fg-red', $this->throwable->description()), PHP_EOL, |
145 | | - Color::colorize('fg-red', $this->throwable->stackTrace()), PHP_EOL |
146 | | - ; |
147 | | - |
148 | | - $this->throwable = null; |
149 | | - } |
150 | | - |
151 | | - while ($this->status === TestStatus::Errored && $this->throwable) { |
152 | | - echo PHP_EOL, Color::colorize('fg-white,bg-red', " {$this->throwable->className()} "), ' ', |
153 | | - Color::colorize('fg-red', $this->throwable->message()), PHP_EOL, PHP_EOL, |
154 | | - Color::colorize('fg-red', $this->throwable->stackTrace()), PHP_EOL |
155 | | - ; |
156 | | - |
157 | | - if ($this->throwable->hasPrevious()) { |
158 | | - echo Color::colorize('fg-red', 'Caused by'); |
159 | | - |
160 | | - $this->throwable = $this->throwable->previous(); |
161 | | - } else { |
162 | | - $this->throwable = null; |
163 | | - } |
164 | | - } |
165 | | - |
166 | | - if ($this->trace) { |
167 | | - printf( |
168 | | - Color::colorize("fg-{$this->status->getColour()}", '%s%s: %s in %s on line %s%1$s%1$s'), |
169 | | - PHP_EOL, |
170 | | - $this->status->name, |
171 | | - $this->trace->message, |
172 | | - $this->trace->file, |
173 | | - $this->trace->line |
174 | | - ); |
175 | | - |
176 | | - $this->trace = null; |
177 | | - } |
178 | | - |
179 | | - $this->status = null; |
| 131 | + $this->config->theme->onTestFinished(new TestResult( |
| 132 | + $id, |
| 133 | + $this->status, |
| 134 | + $this->totalTests, |
| 135 | + ++$this->testCounter, |
| 136 | + $ms, |
| 137 | + $colour, |
| 138 | + $this->throwable, |
| 139 | + $this->trace, |
| 140 | + )); |
| 141 | + |
| 142 | + $this->trace = $this->throwable = $this->status = null; |
180 | 143 | } |
181 | 144 |
|
182 | 145 | if ($event instanceof \PHPUnit\Event\TestRunner\Finished) { |
|
0 commit comments