Skip to content

Commit 06830af

Browse files
committed
added switches to handle more cases
1 parent e196fd5 commit 06830af

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

src/PrettyPrinter.php

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,31 @@ public function endTest(Test $test, float $time): void
5252
}
5353

5454
$this->write(' ');
55-
$this->writeWithColor($color, $name, false);
55+
56+
switch ($test->getStatus()) {
57+
case 0:
58+
$this->writeWithColor('fg-green', $name, false);
59+
break;
60+
case 1:
61+
$this->writeWithColor('fg-yellow', $name, false);
62+
break;
63+
case 2:
64+
$this->writeWithColor('fg-blue', $name, false);
65+
break;
66+
case 3:
67+
$this->writeWithColor('fg-red', $name, false);
68+
break;
69+
case 4:
70+
$this->writeWithColor('fg-red', $name, false);
71+
break;
72+
case 5:
73+
$this->writeWithColor('fg-magenta', $name, false);
74+
break;
75+
default:
76+
$this->writeWithColor('fg-red', $name, false);
77+
break;
78+
}
79+
5680
$this->write(' ');
5781

5882
$timeColor = $time > 0.5 ? 'fg-yellow' : 'fg-white';
@@ -69,10 +93,28 @@ protected function writeProgress(string $progress): void
6993

7094
$this->previousClassName = $this->className;
7195

72-
if ($progress == '.') {
73-
$this->writeWithColor('fg-green', '', false);
74-
} else {
75-
$this->writeWithColor('fg-red', ' x', false);
96+
switch (strtoupper(preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $progress))) {
97+
case '.':
98+
$this->writeWithColor('fg-green', '', false);
99+
break;
100+
case 'S':
101+
$this->writeWithColor('fg-yellow', '', false);
102+
break;
103+
case 'I':
104+
$this->writeWithColor('fg-blue', '', false);
105+
break;
106+
case 'F':
107+
$this->writeWithColor('fg-red', ' x', false);
108+
break;
109+
case 'E':
110+
$this->writeWithColor('fg-red', '', false);
111+
break;
112+
case 'R':
113+
$this->writeWithColor('fg-magenta', '', false);
114+
break;
115+
default:
116+
$this->writeWithColor('fg-red', ' #', false);
117+
break;
76118
}
77119
}
78120

0 commit comments

Comments
 (0)