11<?php
2+
23declare (strict_types=1 );
34
45namespace ScriptFUSION \Pip ;
2122use PHPUnit \Event \Tracer \Tracer ;
2223use PHPUnit \Util \Color ;
2324
24- final class Printer implements Tracer
25- {
25+ final class Printer implements Tracer {
2626 private readonly array $ performanceThresholds ;
2727
2828 private int $ totalTests ;
@@ -39,17 +39,15 @@ final class Printer implements Tracer
3939
4040 private bool $ flawless = true ;
4141
42- public function __construct (private readonly PipConfig $ config )
43- {
42+ public function __construct (private readonly PipConfig $ config ) {
4443 $ this ->performanceThresholds = [
4544 'red ' => $ config ->perfVslow ,
4645 'yellow ' => $ config ->perfSlow ,
4746 'green ' => 0 ,
4847 ];
4948 }
5049
51- public function trace (Event $ event ): void
52- {
50+ public function trace (Event $ event ): void {
5351 if ($ event instanceof ExecutionStarted) {
5452 $ this ->totalTests = $ event ->testSuite ()->count ();
5553 }
@@ -104,10 +102,15 @@ public function trace(Event $event): void
104102 }
105103
106104 if ($ event instanceof Finished) {
107- $ id = $ event ->test ()->id ();
108- if ($ this ->config ->testNameStrip !== '' ) {
109- $ id = str_replace ($ this ->config ->testNameStrip , '' , $ id );
105+ $ id = $ event ->test ()->name (); // changed
106+ $ id = str_replace ('test ' , '' , $ id ); //changed
107+ $ id = str_replace ('_ ' , ' ' , $ id ); //changed
108+
109+ // change block
110+ if ($ this ->trace && $ this ->status !== TestStatus::Failed && $ this ->status !== TestStatus::Errored) {
111+ $ id .= Color::colorize ('fg-yellow ' , ' → ' . $ this ->trace ->message );
110112 }
113+ // end change block
111114
112115 // Data provider case.
113116 if ($ event ->test ()->isTestMethod () && $ event ->test ()->testData ()->hasDataFromDataProvider ()) {
@@ -130,29 +133,29 @@ public function trace(Event $event): void
130133 }
131134
132135 printf (
133- "%3d%% %s %s %s%s " ,
134- floor (++$ this ->testCounter / $ this ->totalTests * 100 ),
136+ // "%3d%% %s %s %s%s",
137+ " %s %s %s %s%s " ,
138+ // " %s %s%s",
139+ '[ ' . str_pad (floor (++$ this ->testCounter / $ this ->totalTests * 100 ) . '' , 3 , ' ' , STR_PAD_LEFT ) . '%] ' ,
135140 $ this ->status ->getStatusColour () === ''
136141 ? $ this ->status ->getStatusCode ()
137- : Color::colorize ("fg- {$ this ->status ->getStatusColour ()}" , $ this ->status ->getStatusCode ()),
138- Color::colorize (" fg- { $ this -> status -> getColour ()}" , $ id ),
142+ : Color::colorize ("fg- {$ this ->status ->getColour ()}" , $ this ->status ->getStatusCode ()), // changed
143+ Color::colorize (' fg-dim ' , $ id ), // changed
139144 Color::colorize ("fg- $ colour " , "( $ ms ms) " ),
140145 PHP_EOL ,
141146 );
142147
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- ;
148+ // if ($this->status === TestStatus::Failed) {
149+ // echo PHP_EOL, Color::colorize('fg-red', $this->throwable->description()), PHP_EOL,
150+ // Color::colorize('fg-red', $this->throwable->stackTrace()), PHP_EOL;
147151
148- $ this ->throwable = null ;
149- }
152+ // $this->throwable = null;
153+ // }
150154
151155 while ($ this ->status === TestStatus::Errored && $ this ->throwable ) {
152156 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- ;
157+ Color::colorize ('fg-red ' , $ this ->throwable ->message ()), PHP_EOL , PHP_EOL ,
158+ Color::colorize ('fg-red ' , $ this ->throwable ->stackTrace ()), PHP_EOL ;
156159
157160 if ($ this ->throwable ->hasPrevious ()) {
158161 echo Color::colorize ('fg-red ' , 'Caused by ' );
@@ -163,18 +166,18 @@ public function trace(Event $event): void
163166 }
164167 }
165168
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- }
169+ // if ($this->trace) {
170+ // printf(
171+ // Color::colorize("fg-{$this->status->getColour()}", '%s%s: %s in %s on line %s%1$s%1$s'),
172+ // PHP_EOL,
173+ // $this->status->name,
174+ // $this->trace->message,
175+ // $this->trace->file,
176+ // $this->trace->line
177+ // );
178+
179+ // $this->trace = null;
180+ // }
178181
179182 $ this ->status = null ;
180183 }
0 commit comments