php-mock/php-mock-phpunit

Declaration of Codeception\Test\Test::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString():

charlesdeb opened this issue · 3 comments

I have been using PHP-mock-phpunit to mock out some built in PHP functions, and compared to some other PHP mocking libraries I have tried, it seems to work pretty well. And it also seems to integrate OK with CodeCeption's take on PHPUnit tests so that was good.

However, now that my unit tests are running and I switch back to continue on my phpbrowser acceptance tests with CodeCeption, I get the following error:

Codeception PHP Testing Framework v3.1.2
Powered by PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
Running with seed: 

PHP Fatal error:  Declaration of Codeception\Test\Test::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString(): string in /project/vendor/codeception/codeception/src/Codeception/Test/Test.php on line 18

Fatal error: Declaration of Codeception\Test\Test::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString(): string in /projectvendor/codeception/codeception/src/Codeception/Test/Test.php on line 18

and that's where it stops. I can't get the acceptance test to run at all.

If I use composer to uninstall PHP-mock-phpunit, then the acceptance tests fire up fine.

Presumably PHPMock is tweaking some classes behind the scenes and that is breaking things...

Here is my composer.json:

{
    "name": "my project",
    "description": "stuff",
    "require-dev": {
        "phpunit/phpunit": "^8",
        "codeception/codeception": "^3",
        "guzzlehttp/guzzle": "^6.3",
        "captbaritone/mailcatcher-codeception-module": "1.*",
        "codeception/specify": "^1",
        "codeception/stub": "^3",
        "dms/phpunit-arraysubset-asserts": "^0.1.0",
        "php-mock/php-mock-phpunit": "^2.6"
    },
    "require": {
        "mailjet/mailjet-apiv3-php": "^1.4",
        "stripe/stripe-php": "^7.14"
    }
}

Any suggestions?

@charlesdeb

It looks like more an issue with Codeception, see:

these are from versions you are using.

I cannot see any usage of SelfDescribing in this library.

Indeed, that seems very likely - neither of these files are PHPMock files. However, when I add PHPMock to the mix, Codeception stops working... I will link this issue to CodeCeption and see if one of the devs there can shed some light on the matter. Thanks for your speedy response.

Codeception issue: Codeception/Codeception#4978

Seems to be solved in upstream dependency.