-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Q | A |
---|---|
PHPUnit version | 10 |
PHP version | 8.1 |
Installation Method | Composer |
Summary
After upgrading from phpunit/phpunit": "^9.5"
to phpunit/phpunit": "^10.0"
and running command vendor/bin/phpunit
getting error as below:
An error occurred inside PHPUnit.
Message: Subscriber "PHPUnit\Event\Test\DataProviderMethodCalledSubscriber" does not exist or is not an interface
Location: /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/TypeMap.php:97
#0 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/TypeMap.php(42): PHPUnit\Event\TypeMap->ensureSubscriberInterfaceExists('PHPUnit\\Event\\T...')
#1 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(252): PHPUnit\Event\TypeMap->addMapping('PHPUnit\\Event\\T...', 'PHPUnit\\Event\\T...')
#2 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(162): PHPUnit\Event\Facade->registerDefaultTypes(Object(PHPUnit\Event\TypeMap))
#3 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(150): PHPUnit\Event\Facade->typeMap()
#4 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(132): PHPUnit\Event\Facade->deferredDispatcher()
#5 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(45): PHPUnit\Event\Facade->createDispatchingEmitter()
#6 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(32): PHPUnit\Event\Facade->__construct()
#7 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/Event/Facade.php(40): PHPUnit\Event\Facade::instance()
#8 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/src/TextUI/Application.php(86): PHPUnit\Event\Facade::emitter()
#9 /opt/homebrew/var/www/mag2ce/vendor/phpunit/phpunit/phpunit(99): PHPUnit\TextUI\Application->run(Array)
#10 {main}
I saw multiple issues closed with same error like #5408 and #5417 but skeptical if issue is related to multiple phpunit version mixup or some newly introduced changes.
Additional Analysis
As per my current analysis, I am getting error when upgrading from phpunit 9 to 10 and my composer.json file contains autoload section as below:
"autoload": {
"exclude-from-classmap": [
"**/Test/**"
]
},
But when I remove **/Test/**
from above block, command works fine. Looks like phpunit/phpunit/src/Event/TypeMap.php
is missing some of required classes when performing mapping.
Note: Adding **/Test/**
is important from performance's perspective so removing it might not be best idea.
It would be great if someone can help with this or provide some more info if this is indeed related to multiple phpunit
versions mixup.