|
7 | 7 | use PHPUnit\TextUI\TestDirectoryNotFoundException; |
8 | 8 | use PHPUnit\TextUI\TestSuiteMapper; |
9 | 9 | use PHPUnit\TextUI\XmlConfiguration\Configuration; |
| 10 | +use PHPUnit\TextUI\XmlConfiguration\Loader; |
10 | 11 | use Symfony\Component\Console\Command\Command; |
11 | 12 | use Symfony\Component\Console\Input\InputArgument; |
12 | 13 | use Symfony\Component\Console\Input\InputInterface; |
@@ -36,45 +37,20 @@ protected function execute(InputInterface $input, OutputInterface $output) { |
36 | 37 | include_once $bootstrap; |
37 | 38 | $testSuites = $input->getArgument('test-suite'); |
38 | 39 |
|
39 | | - $phpunit_9 = FALSE; |
40 | | - if (!class_exists('\PHPUnit\Util\Configuration')) { |
41 | | - $config = (new \PHPUnit\TextUI\XmlConfiguration\Loader())->load($configFile); |
42 | | - $phpunit_9 = TRUE; |
43 | | - } |
44 | | - else { |
45 | | - $config = \PHPUnit\Util\Configuration::getInstance($configFile); |
46 | | - } |
47 | | - if (empty($testSuites)) { |
48 | | - $testSuites = $phpunit_9 ? $config->testSuite() : $config->getTestSuiteNames(); |
49 | | - } |
50 | | - $testFilenames = []; |
51 | | - if ($phpunit_9) { |
52 | | - foreach (array_map(function (\PHPUnit\TextUI\XmlConfiguration\TestSuite $suite) { |
53 | | - return $suite->name(); |
54 | | - }, iterator_to_array($testSuites)) as $name) { |
55 | | - try { |
56 | | - foreach ((new TestSuiteMapper())->map($testSuites, $name) as $test) { |
57 | | - if ($test instanceof TestCase) { |
58 | | - $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); |
59 | | - } |
60 | | - } |
61 | | - } |
62 | | - catch (TestDirectoryNotFoundException $e) { |
63 | | - continue; |
64 | | - } |
| 40 | + $config = (new Loader())->load($configFile); |
| 41 | + |
| 42 | + foreach ($config->testSuite() as $suite) { |
| 43 | + if ($testSuites && !in_array($suite->name(), $testSuites, TRUE)) { |
| 44 | + continue; |
65 | 45 | } |
66 | | - } |
67 | | - else { |
68 | | - foreach ($testSuites as $suite) { |
69 | | - $suite = $config->getTestSuiteConfiguration($suite); |
70 | | - foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) { |
71 | | - if ($test instanceof TestCase) { |
72 | | - $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); |
73 | | - } |
| 46 | + $testSuite = (new TestSuiteMapper)->map($config->testSuite(), $suite->name()); |
| 47 | + foreach (new \RecursiveIteratorIterator($testSuite) as $test) { |
| 48 | + if ($test instanceof TestCase) { |
| 49 | + $testFilenames[] = ((new \ReflectionClass($test))->getFileName()); |
74 | 50 | } |
75 | 51 | } |
76 | | - |
77 | 52 | } |
| 53 | + |
78 | 54 | $testFilenames = array_unique($testFilenames); |
79 | 55 | foreach ($testFilenames as $testFilename) { |
80 | 56 | $output->writeln($testFilename); |
|
0 commit comments