File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1313use const PHP_VERSION ;
1414use function assert ;
1515use function class_exists ;
16+ use function defined ;
17+ use function dirname ;
1618use function explode ;
1719use function function_exists ;
1820use function is_file ;
2224use function realpath ;
2325use function sprintf ;
2426use function str_contains ;
27+ use function str_starts_with ;
2528use function trim ;
2629use function unlink ;
2730use PHPUnit \Event \EventFacadeIsSealedException ;
100103 */
101104 public function run (array $ argv ): int
102105 {
106+ $ this ->preload ();
107+
103108 try {
104109 EventFacade::emitter ()->applicationStarted ();
105110
@@ -841,4 +846,30 @@ private function configureDeprecationTriggers(Configuration $configuration): voi
841846
842847 ErrorHandler::instance ()->useDeprecationTriggers ($ deprecationTriggers );
843848 }
849+
850+ private function preload (): void
851+ {
852+ if (!defined ('PHPUNIT_COMPOSER_INSTALL ' )) {
853+ return ;
854+ }
855+
856+ $ classMapFile = dirname (PHPUNIT_COMPOSER_INSTALL ) . '/composer/autoload_classmap.php ' ;
857+
858+ if (!is_file ($ classMapFile )) {
859+ return ;
860+ }
861+
862+ foreach (require $ classMapFile as $ codeUnitName => $ sourceCodeFile ) {
863+ if (!str_starts_with ($ codeUnitName , 'PHPUnit \\' ) &&
864+ !str_starts_with ($ codeUnitName , 'SebastianBergmann \\' )) {
865+ continue ;
866+ }
867+
868+ if (str_contains ($ sourceCodeFile , '/tests/ ' )) {
869+ continue ;
870+ }
871+
872+ require_once $ sourceCodeFile ;
873+ }
874+ }
844875}
You can’t perform that action at this time.
0 commit comments