9
9
*/
10
10
namespace PHPUnit \TextUI \Command ;
11
11
12
- use function array_intersect ;
13
12
use function array_unique ;
13
+ use function assert ;
14
14
use function sprintf ;
15
15
use PHPUnit \Framework \TestCase ;
16
- use PHPUnit \Framework \TestSuite ;
17
16
use PHPUnit \Runner \PhptTestCase ;
18
17
use PHPUnit \TextUI \Configuration \Registry ;
19
- use RecursiveIteratorIterator ;
20
18
use ReflectionClass ;
21
19
use ReflectionException ;
22
20
25
23
*/
26
24
final readonly class ListTestFilesCommand implements Command
27
25
{
28
- private TestSuite $ suite ;
26
+ /**
27
+ * @psalm-var list<TestCase|PhptTestCase>
28
+ */
29
+ private array $ tests ;
29
30
30
- public function __construct (TestSuite $ suite )
31
+ /**
32
+ * @psalm-param list<TestCase|PhptTestCase> $tests
33
+ */
34
+ public function __construct (array $ tests )
31
35
{
32
- $ this ->suite = $ suite ;
36
+ $ this ->tests = $ tests ;
33
37
}
34
38
35
39
/**
@@ -43,30 +47,18 @@ public function execute(): Result
43
47
44
48
$ results = [];
45
49
46
- foreach (new RecursiveIteratorIterator ( $ this ->suite ) as $ test ) {
50
+ foreach ($ this ->tests as $ test ) {
47
51
if ($ test instanceof TestCase) {
48
52
$ name = (new ReflectionClass ($ test ))->getFileName ();
49
53
50
- // @codeCoverageIgnoreStart
51
- if ($ name === false ) {
52
- continue ;
53
- }
54
- // @codeCoverageIgnoreEnd
54
+ assert ($ name !== false );
55
55
56
- if ($ configuration ->hasGroups () && empty (array_intersect ($ configuration ->groups (), $ test ->groups ()))) {
57
- continue ;
58
- }
56
+ $ results [] = $ name ;
59
57
60
- if ($ configuration ->hasExcludeGroups () && !empty (array_intersect ($ configuration ->excludeGroups (), $ test ->groups ()))) {
61
- continue ;
62
- }
63
- } elseif ($ test instanceof PhptTestCase) {
64
- $ name = $ test ->getName ();
65
- } else {
66
58
continue ;
67
59
}
68
60
69
- $ results [] = $ name ;
61
+ $ results [] = $ test -> getName () ;
70
62
}
71
63
72
64
foreach (array_unique ($ results ) as $ result ) {
0 commit comments