Skip to content

Subscriber "PHPUnit\Event\Test\DataProviderMethodCalledSubscriber" does not exist or is not an interface #5570

@nishant04412

Description

@nishant04412
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is brokenversion/10Something affects PHPUnit 10

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions