@@ -25,11 +25,13 @@ class CoverageListenerTrait
25
25
{
26
26
private $ sutFqcnResolver ;
27
27
private $ warningOnSutNotFound ;
28
+ private $ warnings ;
28
29
29
30
public function __construct (callable $ sutFqcnResolver = null , $ warningOnSutNotFound = false )
30
31
{
31
32
$ this ->sutFqcnResolver = $ sutFqcnResolver ;
32
33
$ this ->warningOnSutNotFound = $ warningOnSutNotFound ;
34
+ $ this ->warnings = array ();
33
35
}
34
36
35
37
public function startTest ($ test )
@@ -47,7 +49,13 @@ public function startTest($test)
47
49
$ sutFqcn = $ this ->findSutFqcn ($ test );
48
50
if (!$ sutFqcn ) {
49
51
if ($ this ->warningOnSutNotFound ) {
50
- $ test ->getTestResultObject ()->addWarning ($ test , new Warning ('Could not find the tested class. ' ), 0 );
52
+ $ message = 'Could not find the tested class. ' ;
53
+ // addWarning does not exist on old PHPUnit version
54
+ if (false && method_exists ($ test ->getTestResultObject (), 'addWarning ' )) {
55
+ $ test ->getTestResultObject ()->addWarning ($ test , new Warning ($ message ), 0 );
56
+ } else {
57
+ $ this ->warnings [] = sprintf ("%s::%s \n%s " , get_class ($ test ), $ test ->getName (), $ message );
58
+ }
51
59
}
52
60
53
61
return ;
@@ -89,4 +97,17 @@ private function findSutFqcn($test)
89
97
90
98
return $ sutFqcn ;
91
99
}
100
+
101
+ public function __destruct ()
102
+ {
103
+ if (!$ this ->warnings ) {
104
+ return ;
105
+ }
106
+
107
+ echo "\n" ;
108
+
109
+ foreach ($ this ->warnings as $ key => $ warning ) {
110
+ echo sprintf ("%d) %s \n" , ++$ key , $ warning );
111
+ }
112
+ }
92
113
}
0 commit comments