Skip to content

Commit f6b6296

Browse files
staabmsebastianbergmann
authored andcommitted
test --testdox with colors
1 parent ca37d7f commit f6b6296

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

src/TextUI/Output/TestDox/ResultPrinter.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use const PHP_EOL;
1313
use function array_map;
14-
use function assert;
1514
use function explode;
1615
use function implode;
1716
use function preg_match;
@@ -248,9 +247,7 @@ private function printThrowable(TestStatus $status, Throwable $throwable): void
248247
} else {
249248
$tracePrefix = $this->prefixFor('trace', $status);
250249
}
251-
}
252250

253-
if ($stackTrace !== '') {
254251
$this->printer->print(
255252
$this->prefixLines($tracePrefix, PHP_EOL . $stackTrace),
256253
);
@@ -261,7 +258,7 @@ private function printThrowable(TestStatus $status, Throwable $throwable): void
261258

262259
$this->printer->print(
263260
$this->prefixLines(
264-
$tracePrefix,
261+
$this->prefixFor('default', $status),
265262
' ',
266263
),
267264
);
@@ -270,7 +267,7 @@ private function printThrowable(TestStatus $status, Throwable $throwable): void
270267

271268
$this->printer->print(
272269
$this->prefixLines(
273-
$tracePrefix,
270+
$this->prefixFor('default', $status),
274271
'Caused by:',
275272
),
276273
);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Testdox: print error message
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--display-errors';
6+
$_SERVER['argv'][] = '--do-not-cache-result';
7+
$_SERVER['argv'][] = '--no-configuration';
8+
$_SERVER['argv'][] = '--no-progress';
9+
$_SERVER['argv'][] = '--testdox';
10+
$_SERVER['argv'][] = '--colors=always';
11+
$_SERVER['argv'][] = __DIR__ . '/../_files/ThrowsWithPreviousExceptionTest.php';
12+
13+
require_once __DIR__ . '/../../../bootstrap.php';
14+
15+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
16+
--EXPECTF--
17+
PHPUnit %s by Sebastian Bergmann and contributors.
18+
19+
Runtime: PHP %s
20+
21+
Time: %s, Memory: %s
22+
23+
Throws With Previous Exception (PHPUnit\TestFixture\ThrowsWithPreviousException)
24+
 ✘ Foo
25+
┐
26+
├ Exception: Outer
27+
│
28+
│ %sThrowsWithPreviousExceptionTest.php:%d%A
29+
│ Caused by:
30+
├ Exception: Inner
31+
│
32+
│ %sThrowsWithPreviousExceptionTest.php:%d%A
33+
┴
34+
35+
ERRORS!
36+
Tests: 1, Assertions: 0, Errors: 1.

0 commit comments

Comments
 (0)