Codeception / Stub

Flexible Stub wrapper for PHPUnit's Mock Builder
MIT License
296 stars 17 forks source link

Stub make methods fails with: Class "PHPUnit\Framework\MockObject\Generator" not found #41

Closed SUN5H1N3 closed 1 year ago

SUN5H1N3 commented 1 year ago

I trying to make stub by Stub::make() method

But i get error: Class "PHPUnit\Framework\MockObject\Generator" not found

Console output:


  [Error] Class "PHPUnit\Framework\MockObject\Generator" not found  

/var/www/html/app/vendor/codeception/stub/src/Stub.php:436
/var/www/html/app/vendor/codeception/stub/src/Stub.php:417
/var/www/html/app/vendor/codeception/stub/src/Stub.php:90
/var/www/html/app/tests/functional/CurrencyRateServiceCest.php:45
/var/www/html/app/tests/functional/CurrencyRateServiceCest.php:26
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Lib/Di.php:130
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Test/Cest.php:184
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Test/Cest.php:200
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Test/Cest.php:129
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Test/Test.php:168
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Suite.php:130
/var/www/html/app/vendor/codeception/codeception/src/Codeception/SuiteManager.php:148
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Codecept.php:260
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Codecept.php:216
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Command/Run.php:435
/var/www/html/app/vendor/symfony/console/Command/Command.php:326
/var/www/html/app/vendor/symfony/console/Application.php:1075
/var/www/html/app/vendor/symfony/console/Application.php:324
/var/www/html/app/vendor/symfony/console/Application.php:175
/var/www/html/app/vendor/codeception/codeception/src/Codeception/Application.php:112
/var/www/html/app/vendor/codeception/codeception/app.php:45
/var/www/html/app/vendor/codeception/codeception/app.php:46
/var/www/html/app/vendor/codeception/codeception/codecept:7
/var/www/html/app/vendor/bin/codecept:119
/var/www/html/app/codecept:4

This is because you have "phpunit/phpunit": "^9.5.20 || ^10.0" in your composer.json. Because of this, when i install codeception, the 10th version of phpunit is installed. But in this version of phpunit PHPUnit\Framework\MockObject\Generator has been moved to PHPUnit\Framework\MockObject\Generator\Generator. If I specificaly add to my composer.json "phpunit/phpunit": "^9.5.20" to force the use of the 9th one, then everything starts working properly.

Details

actor: FunctionalTester
modules:
    enabled:
        - Asserts
        - Yii2:
            part: [orm, email, fixtures]
        - Db
        - DataFactory
extensions:
    enabled: [app\tests\support\DumpExtension]
Naktibalda commented 1 year ago

@SUN5H1N3 I moved your issue to correct repository.

W0rma commented 1 year ago

But i get error: Class "PHPUnit\Framework\MockObject\Generator" not found

@SUN5H1N3 Which version of PHPUnit did you use? Was it 10.3?

https://github.com/Codeception/Stub/pull/42 should fix it.