41
41
use PHPUnit \Event \UnknownSubscriberTypeException ;
42
42
use PHPUnit \Framework \TestStatus \TestStatus ;
43
43
use PHPUnit \Logging \TestDox \TestResult as TestDoxTestMethod ;
44
- use PHPUnit \TextUI \Configuration \Source ;
45
- use PHPUnit \TextUI \Configuration \SourceFilter ;
44
+ use PHPUnit \TestRunner \IssueFilter ;
46
45
use ReflectionMethod ;
47
46
48
47
/**
52
51
*/
53
52
final class TestResultCollector
54
53
{
55
- private readonly Source $ source ;
54
+ private readonly IssueFilter $ issueFilter ;
56
55
57
56
/**
58
57
* @var array<string, list<TestDoxTestMethod>>
@@ -66,9 +65,9 @@ final class TestResultCollector
66
65
* @throws EventFacadeIsSealedException
67
66
* @throws UnknownSubscriberTypeException
68
67
*/
69
- public function __construct (Facade $ facade , Source $ source )
68
+ public function __construct (Facade $ facade , IssueFilter $ issueFilter )
70
69
{
71
- $ this ->source = $ source ;
70
+ $ this ->issueFilter = $ issueFilter ;
72
71
73
72
$ this ->registerSubscribers ($ facade );
74
73
}
@@ -216,135 +215,79 @@ public function testConsideredRisky(ConsideredRisky $event): void
216
215
217
216
public function testTriggeredDeprecation (DeprecationTriggered $ event ): void
218
217
{
219
- if (!$ event ->test ()->isTestMethod ()) {
220
- return ;
221
- }
222
-
223
- if ($ event ->ignoredByTest ()) {
218
+ if (!$ this ->issueFilter ->shouldBeProcessed ($ event , true )) {
224
219
return ;
225
220
}
226
221
227
222
if ($ event ->ignoredByBaseline ()) {
228
223
return ;
229
224
}
230
225
231
- if (!$ this ->source ->ignoreSuppressionOfDeprecations () && $ event ->wasSuppressed ()) {
232
- return ;
233
- }
234
-
235
- if ($ this ->source ->restrictDeprecations () && !(new SourceFilter )->includes ($ this ->source , $ event ->file ())) {
236
- return ;
237
- }
238
-
239
226
$ this ->updateTestStatus (TestStatus::deprecation ());
240
227
}
241
228
242
229
public function testTriggeredNotice (NoticeTriggered $ event ): void
243
230
{
244
- if (!$ event -> test ()-> isTestMethod ( )) {
231
+ if (!$ this -> issueFilter -> shouldBeProcessed ( $ event , true )) {
245
232
return ;
246
233
}
247
234
248
235
if ($ event ->ignoredByBaseline ()) {
249
236
return ;
250
237
}
251
238
252
- if (!$ this ->source ->ignoreSuppressionOfNotices () && $ event ->wasSuppressed ()) {
253
- return ;
254
- }
255
-
256
- if ($ this ->source ->restrictNotices () && !(new SourceFilter )->includes ($ this ->source , $ event ->file ())) {
257
- return ;
258
- }
259
-
260
239
$ this ->updateTestStatus (TestStatus::notice ());
261
240
}
262
241
263
242
public function testTriggeredWarning (WarningTriggered $ event ): void
264
243
{
265
- if (!$ event -> test ()-> isTestMethod ( )) {
244
+ if (!$ this -> issueFilter -> shouldBeProcessed ( $ event , true )) {
266
245
return ;
267
246
}
268
247
269
248
if ($ event ->ignoredByBaseline ()) {
270
249
return ;
271
250
}
272
251
273
- if (!$ this ->source ->ignoreSuppressionOfWarnings () && $ event ->wasSuppressed ()) {
274
- return ;
275
- }
276
-
277
- if ($ this ->source ->restrictWarnings () && !(new SourceFilter )->includes ($ this ->source , $ event ->file ())) {
278
- return ;
279
- }
280
-
281
252
$ this ->updateTestStatus (TestStatus::warning ());
282
253
}
283
254
284
255
public function testTriggeredPhpDeprecation (PhpDeprecationTriggered $ event ): void
285
256
{
286
- if (!$ event -> test ()-> isTestMethod ( )) {
257
+ if (!$ this -> issueFilter -> shouldBeProcessed ( $ event , true )) {
287
258
return ;
288
259
}
289
260
290
261
if ($ event ->ignoredByTest ()) {
291
262
return ;
292
263
}
293
264
294
- if ($ event ->ignoredByBaseline ()) {
295
- return ;
296
- }
297
-
298
- if (!$ this ->source ->ignoreSuppressionOfPhpDeprecations () && $ event ->wasSuppressed ()) {
299
- return ;
300
- }
301
-
302
- if ($ this ->source ->restrictDeprecations () && !(new SourceFilter )->includes ($ this ->source , $ event ->file ())) {
303
- return ;
304
- }
305
-
306
265
$ this ->updateTestStatus (TestStatus::deprecation ());
307
266
}
308
267
309
268
public function testTriggeredPhpNotice (PhpNoticeTriggered $ event ): void
310
269
{
311
- if (!$ event -> test ()-> isTestMethod ( )) {
270
+ if (!$ this -> issueFilter -> shouldBeProcessed ( $ event , true )) {
312
271
return ;
313
272
}
314
273
315
274
if ($ event ->ignoredByBaseline ()) {
316
275
return ;
317
276
}
318
277
319
- if (!$ this ->source ->ignoreSuppressionOfPhpNotices () && $ event ->wasSuppressed ()) {
320
- return ;
321
- }
322
-
323
- if ($ this ->source ->restrictNotices () && !(new SourceFilter )->includes ($ this ->source , $ event ->file ())) {
324
- return ;
325
- }
326
-
327
278
$ this ->updateTestStatus (TestStatus::notice ());
328
279
}
329
280
330
281
public function testTriggeredPhpWarning (PhpWarningTriggered $ event ): void
331
282
{
332
- if (!$ event -> test ()-> isTestMethod ( )) {
283
+ if (!$ this -> issueFilter -> shouldBeProcessed ( $ event , true )) {
333
284
return ;
334
285
}
335
286
336
287
if ($ event ->ignoredByBaseline ()) {
337
288
return ;
338
289
}
339
290
340
- if (!$ this ->source ->ignoreSuppressionOfPhpWarnings () && $ event ->wasSuppressed ()) {
341
- return ;
342
- }
343
-
344
- if ($ this ->source ->restrictWarnings () && !(new SourceFilter )->includes ($ this ->source , $ event ->file ())) {
345
- return ;
346
- }
347
-
348
291
$ this ->updateTestStatus (TestStatus::warning ());
349
292
}
350
293
0 commit comments