@@ -47,7 +47,13 @@ public function load(string $suiteClassFile): ReflectionClass
47
47
);
48
48
49
49
if (empty ($ loadedClasses )) {
50
- throw $ this ->exceptionFor ($ suiteClassName , $ suiteClassFile );
50
+ throw new Exception (
51
+ sprintf (
52
+ 'Class %s could not be found in %s ' ,
53
+ $ suiteClassName ,
54
+ $ suiteClassFile
55
+ )
56
+ );
51
57
}
52
58
}
53
59
@@ -66,7 +72,13 @@ public function load(string $suiteClassFile): ReflectionClass
66
72
}
67
73
68
74
if (!class_exists ($ suiteClassName , false )) {
69
- throw $ this ->exceptionFor ($ suiteClassName , $ suiteClassFile );
75
+ throw new Exception (
76
+ sprintf (
77
+ 'Class %s could not be found in %s ' ,
78
+ $ suiteClassName ,
79
+ $ suiteClassFile
80
+ )
81
+ );
70
82
}
71
83
72
84
try {
@@ -81,7 +93,17 @@ public function load(string $suiteClassFile): ReflectionClass
81
93
}
82
94
// @codeCoverageIgnoreEnd
83
95
84
- if ($ class ->isSubclassOf (TestCase::class) && !$ class ->isAbstract ()) {
96
+ if ($ class ->isSubclassOf (TestCase::class)) {
97
+ if ($ class ->isAbstract ()) {
98
+ throw new Exception (
99
+ sprintf (
100
+ 'Class %s declared in %s is abstract ' ,
101
+ $ suiteClassName ,
102
+ $ suiteClassFile
103
+ )
104
+ );
105
+ }
106
+
85
107
return $ class ;
86
108
}
87
109
@@ -91,34 +113,40 @@ public function load(string $suiteClassFile): ReflectionClass
91
113
// @codeCoverageIgnoreStart
92
114
} catch (ReflectionException $ e ) {
93
115
throw new Exception (
94
- $ e ->getMessage (),
95
- $ e ->getCode (),
96
- $ e
116
+ sprintf (
117
+ 'Method %s::suite() declared in %s is abstract ' ,
118
+ $ suiteClassName ,
119
+ $ suiteClassFile
120
+ )
97
121
);
98
122
}
99
- // @codeCoverageIgnoreEnd
100
123
101
- if (!$ method ->isAbstract () && $ method ->isPublic () && $ method ->isStatic ()) {
102
- return $ class ;
124
+ if (!$ method ->isPublic ()) {
125
+ throw new Exception (
126
+ sprintf (
127
+ 'Method %s::suite() declared in %s is not public ' ,
128
+ $ suiteClassName ,
129
+ $ suiteClassFile
130
+ )
131
+ );
132
+ }
133
+
134
+ if (!$ method ->isStatic ()) {
135
+ throw new Exception (
136
+ sprintf (
137
+ 'Method %s::suite() declared in %s is not static ' ,
138
+ $ suiteClassName ,
139
+ $ suiteClassFile
140
+ )
141
+ );
103
142
}
104
143
}
105
144
106
- throw $ this -> exceptionFor ( $ suiteClassName , $ suiteClassFile ) ;
145
+ return $ class ;
107
146
}
108
147
109
148
public function reload (ReflectionClass $ aClass ): ReflectionClass
110
149
{
111
150
return $ aClass ;
112
151
}
113
-
114
- private function exceptionFor (string $ className , string $ filename ): Exception
115
- {
116
- return new Exception (
117
- sprintf (
118
- "Class '%s' could not be found in '%s'. " ,
119
- $ className ,
120
- $ filename
121
- )
122
- );
123
- }
124
152
}
0 commit comments