Codeception: Codeception/Test classes with Interface Descriptive has problem with phpunit 7 typehint from Interface PHPUnit\Framework\SelfDescribing
What are you trying to achieve?
Using codeception 2.4 with phpunit 7.1.5 and want to start the tests via console vendor/bin/codecept run
What do you get instead?
It breaks with a Fatal Error:
Compile Error: Declaration of Codeception\Test\Test::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString(): string
Details
- Codeception version: 2.4
- phpunit version: 7.1.5
- PHP Version: 7.2.6
- Operating System: Ubuntu 16.04
- Installation type: Composer
codeception 2.4 with phpunit < 7 (in my case phpunit 6.5.8) works as expected.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29 (21 by maintainers)
Commits related to this issue
- ci(monorepo): remove rector Rector is not compatible with codeception v4. See: https://github.com/rectorphp/rector/issues/6531 See: https://github.com/Codeception/Codeception/issues/5031 — committed to snicco/snicco by calvinalkan 2 years ago
- ci(better-wp-cli): remove rector and coverage for wpcliapplication.php It currently does not look like the WPCLI/CLI module supports collecting coverage. We have to revisit this when we have a respon... — committed to snicco/snicco by calvinalkan 2 years ago
I think the problem is that the phpunit-wapper only works if the
PHPUnit\Framework\SelfDescribing
is not loaded beforeCodeception\PHPUnit\Init::init()
is executed.My dependencies are:
Tests:
If I remove all dev dependencies except codeception from my project it works. Because the
!interface_exists(SelfDescribing::class, false)
return true.If I only add phpunit and codeception to the dependency it also works. Because the
!interface_exists(SelfDescribing::class, false)
return true.If I install phpunit, codeception and symfony/phpunit-bridge it also works. Because the
!interface_exists(SelfDescribing::class, false)
return true.But if I install php-mock/php-mock-phpunit I got the error, because php-mock-phpunit also have an autoload-file which defines some class-aliases and when it calls the
interface_exists(\PHPUnit\Framework\MockObject\Matcher\Invocation::class)
function the autoloader kicks in and load the interface and it’s parents interfaces in the ram. So the!interface_exists(SelfDescribing::class, false)
return false and the orignal interface is loaded.So maybe you should add php-mock/php-mock-phpunit to the conflicts section in your composer.json But this don’t fix the loading issue.
@DavertMik I’m hitting the same issue. I actually commented on #4978 about it, but since this ticket’s open, I’ll re-post my output here:
Here’s a truncated output of my
composer show
, to prove I’m running the latest of Codeception and PHPUnit Wrapper:@DavertMik why does codeception 3.0 still support PHP 5.6? Wasn’t this the perfect chance to get a rid of the dependency? Because otherwise it is not possible to use codeception with phpunit 7/8 and php >=7.1 or is there a other way?
@DavertMik Any update on this by chance? I noticed some updates around 7.2 support, so I updated codeception/codeception to 2.4.5, phpunit/phpunit to 7.2.7, and codeception/phpunit-wrapper to 7.2.0, but I’m still hitting the same error.
If you need a more detailed proof of concept, let me know, and I’ll take another look at what the most minimal repro steps are.