21
21
*/
22
22
final class TestSuiteFilterProcessor
23
23
{
24
- private Factory $ filterFactory ;
25
-
26
- public function __construct (Factory $ factory = new Factory )
27
- {
28
- $ this ->filterFactory = $ factory ;
29
- }
30
-
31
24
/**
32
25
* @throws Event\RuntimeException
33
26
* @throws FilterNotConfiguredException
34
27
*/
35
28
public function process (Configuration $ configuration , TestSuite $ suite ): void
36
29
{
30
+ $ factory = new Factory ;
31
+
37
32
if (!$ configuration ->hasFilter () &&
38
33
!$ configuration ->hasGroups () &&
39
34
!$ configuration ->hasExcludeGroups () &&
@@ -43,19 +38,19 @@ public function process(Configuration $configuration, TestSuite $suite): void
43
38
}
44
39
45
40
if ($ configuration ->hasExcludeGroups ()) {
46
- $ this -> filterFactory ->addExcludeGroupFilter (
41
+ $ factory ->addExcludeGroupFilter (
47
42
$ configuration ->excludeGroups (),
48
43
);
49
44
}
50
45
51
46
if ($ configuration ->hasGroups ()) {
52
- $ this -> filterFactory ->addIncludeGroupFilter (
47
+ $ factory ->addIncludeGroupFilter (
53
48
$ configuration ->groups (),
54
49
);
55
50
}
56
51
57
52
if ($ configuration ->hasTestsCovering ()) {
58
- $ this -> filterFactory ->addIncludeGroupFilter (
53
+ $ factory ->addIncludeGroupFilter (
59
54
array_map (
60
55
static fn (string $ name ): string => '__phpunit_covers_ ' . $ name ,
61
56
$ configuration ->testsCovering (),
@@ -64,7 +59,7 @@ public function process(Configuration $configuration, TestSuite $suite): void
64
59
}
65
60
66
61
if ($ configuration ->hasTestsUsing ()) {
67
- $ this -> filterFactory ->addIncludeGroupFilter (
62
+ $ factory ->addIncludeGroupFilter (
68
63
array_map (
69
64
static fn (string $ name ): string => '__phpunit_uses_ ' . $ name ,
70
65
$ configuration ->testsUsing (),
@@ -73,12 +68,12 @@ public function process(Configuration $configuration, TestSuite $suite): void
73
68
}
74
69
75
70
if ($ configuration ->hasFilter ()) {
76
- $ this -> filterFactory ->addNameFilter (
71
+ $ factory ->addNameFilter (
77
72
$ configuration ->filter (),
78
73
);
79
74
}
80
75
81
- $ suite ->injectFilter ($ this -> filterFactory );
76
+ $ suite ->injectFilter ($ factory );
82
77
83
78
Event \Facade::emitter ()->testSuiteFiltered (
84
79
Event \TestSuite \TestSuiteBuilder::from ($ suite ),
0 commit comments