Skip to content

Commit 0dc7a39

Browse files
committed
Merge branch 'hotfix/1.0.7'
2 parents 415d2a2 + 4130fe2 commit 0dc7a39

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/storage/*.key
55
/vendor
66
/.idea
7+
/.vscode
78
/.vagrant
89
Homestead.json
910
Homestead.yaml

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "sempro/phpunit-pretty-print",
3+
"version": "1.0.7",
34
"description": "Prettify PHPUnit output",
45
"type": "library",
56
"license": "MIT",
67
"minimum-stability": "dev",
7-
"prefer-stable" : true,
8+
"prefer-stable": true,
89
"require": {
910
"php": ">=7.0.0",
1011
"phpunit/phpunit": ">=7.0.0"
@@ -14,4 +15,4 @@
1415
"Sempro\\PHPUnitPrettyPrinter\\": "src/"
1516
}
1617
}
17-
}
18+
}

src/PrettyPrinter.php

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPUnit\Framework\TestFailure;
77
use PHPUnit\Framework\TestListener;
88
use PHPUnit\Framework\TestSuite;
9+
use PHPUnit\Runner\BaseTestRunner;
910
use PHPUnit\TextUI\ResultPrinter;
1011
use PHPUnit\Util\Filter;
1112

@@ -52,7 +53,35 @@ public function endTest(Test $test, float $time): void
5253
}
5354

5455
$this->write(' ');
55-
$this->writeWithColor($color, $name, false);
56+
57+
switch ($test->getStatus()) {
58+
case BaseTestRunner::STATUS_PASSED:
59+
$this->writeWithColor('fg-green', $name, false);
60+
break;
61+
case BaseTestRunner::STATUS_SKIPPED:
62+
$this->writeWithColor('fg-yellow', $name, false);
63+
break;
64+
case BaseTestRunner::STATUS_INCOMPLETE:
65+
$this->writeWithColor('fg-blue', $name, false);
66+
break;
67+
case BaseTestRunner::STATUS_FAILURE:
68+
$this->writeWithColor('fg-red', $name, false);
69+
break;
70+
case BaseTestRunner::STATUS_ERROR:
71+
$this->writeWithColor('fg-red', $name, false);
72+
break;
73+
case BaseTestRunner::STATUS_RISKY:
74+
$this->writeWithColor('fg-magenta', $name, false);
75+
break;
76+
case BaseTestRunner::STATUS_WARNING:
77+
$this->writeWithColor('fg-yellow', $name, false);
78+
break;
79+
case BaseTestRunner::STATUS_UNKNOWN:
80+
default:
81+
$this->writeWithColor('fg-cyan', $name, false);
82+
break;
83+
}
84+
5685
$this->write(' ');
5786

5887
$timeColor = $time > 0.5 ? 'fg-yellow' : 'fg-white';
@@ -69,10 +98,31 @@ protected function writeProgress(string $progress): void
6998

7099
$this->previousClassName = $this->className;
71100

72-
if ($progress == '.') {
73-
$this->writeWithColor('fg-green', '', false);
74-
} else {
75-
$this->writeWithColor('fg-red', ' x', false);
101+
switch (strtoupper(preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $progress))) {
102+
case '.':
103+
$this->writeWithColor('fg-green', '', false);
104+
break;
105+
case 'S':
106+
$this->writeWithColor('fg-yellow', '', false);
107+
break;
108+
case 'I':
109+
$this->writeWithColor('fg-blue', '', false);
110+
break;
111+
case 'F':
112+
$this->writeWithColor('fg-red', ' x', false);
113+
break;
114+
case 'E':
115+
$this->writeWithColor('fg-red', '', false);
116+
break;
117+
case 'R':
118+
$this->writeWithColor('fg-magenta', '', false);
119+
break;
120+
case 'W':
121+
$this->writeWithColor('fg-yellow', ' ¤', false);
122+
break;
123+
default:
124+
$this->writeWithColor('fg-cyan', '', false);
125+
break;
76126
}
77127
}
78128

0 commit comments

Comments
 (0)