|
35 | 35 | use function strpos;
|
36 | 36 | use function trim;
|
37 | 37 | use function version_compare;
|
38 |
| -use PharIo\Manifest\ApplicationName; |
39 |
| -use PharIo\Manifest\Exception as ManifestException; |
40 |
| -use PharIo\Manifest\ManifestLoader; |
41 |
| -use PharIo\Version\Version as PharIoVersion; |
42 | 38 | use PHPUnit\Framework\TestSuite;
|
| 39 | +use PHPUnit\Runner\ExtensionHandler; |
43 | 40 | use PHPUnit\Runner\StandardTestSuiteLoader;
|
44 | 41 | use PHPUnit\Runner\TestSuiteLoader;
|
45 | 42 | use PHPUnit\Runner\Version;
|
|
61 | 58 | use ReflectionClass;
|
62 | 59 | use SebastianBergmann\CodeCoverage\Filter;
|
63 | 60 | use SebastianBergmann\CodeCoverage\StaticAnalysis\CacheWarmer;
|
64 |
| -use SebastianBergmann\FileIterator\Facade as FileIteratorFacade; |
65 | 61 | use SebastianBergmann\Timer\Timer;
|
66 | 62 | use Throwable;
|
67 | 63 |
|
@@ -352,7 +348,12 @@ protected function handleArguments(array $argv): void
|
352 | 348 | }
|
353 | 349 |
|
354 | 350 | if (!isset($this->arguments['noExtensions']) && $phpunitConfiguration->hasExtensionsDirectory() && extension_loaded('phar')) {
|
355 |
| - $this->handleExtensions($phpunitConfiguration->extensionsDirectory()); |
| 351 | + $result = (new ExtensionHandler)->handle($phpunitConfiguration->extensionsDirectory()); |
| 352 | + |
| 353 | + $this->arguments['loadedExtensions'] = $result['loadedExtensions']; |
| 354 | + $this->arguments['notLoadedExtensions'] = $result['notLoadedExtensions']; |
| 355 | + |
| 356 | + unset($result); |
356 | 357 | }
|
357 | 358 |
|
358 | 359 | if (!isset($this->arguments['columns'])) {
|
@@ -611,43 +612,6 @@ private function exitWithErrorMessage(string $message): void
|
611 | 612 | exit(TestRunner::FAILURE_EXIT);
|
612 | 613 | }
|
613 | 614 |
|
614 |
| - private function handleExtensions(string $directory): void |
615 |
| - { |
616 |
| - foreach ((new FileIteratorFacade)->getFilesAsArray($directory, '.phar') as $file) { |
617 |
| - if (!is_file('phar://' . $file . '/manifest.xml')) { |
618 |
| - $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit'; |
619 |
| - |
620 |
| - continue; |
621 |
| - } |
622 |
| - |
623 |
| - try { |
624 |
| - $applicationName = new ApplicationName('phpunit/phpunit'); |
625 |
| - $version = new PharIoVersion(Version::series()); |
626 |
| - $manifest = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml'); |
627 |
| - |
628 |
| - if (!$manifest->isExtensionFor($applicationName)) { |
629 |
| - $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit'; |
630 |
| - |
631 |
| - continue; |
632 |
| - } |
633 |
| - |
634 |
| - if (!$manifest->isExtensionFor($applicationName, $version)) { |
635 |
| - $this->arguments['notLoadedExtensions'][] = $file . ' is not compatible with this version of PHPUnit'; |
636 |
| - |
637 |
| - continue; |
638 |
| - } |
639 |
| - } catch (ManifestException $e) { |
640 |
| - $this->arguments['notLoadedExtensions'][] = $file . ': ' . $e->getMessage(); |
641 |
| - |
642 |
| - continue; |
643 |
| - } |
644 |
| - |
645 |
| - require $file; |
646 |
| - |
647 |
| - $this->arguments['loadedExtensions'][] = $manifest->getName()->asString() . ' ' . $manifest->getVersion()->getVersionString(); |
648 |
| - } |
649 |
| - } |
650 |
| - |
651 | 615 | private function handleListGroups(TestSuite $suite, bool $exit): int
|
652 | 616 | {
|
653 | 617 | $this->printVersionString();
|
|
0 commit comments