Run unit tests generated by Codeception
A very annoying warning message
Provide console output if related. Use
-vvvmode for more details.
Warning: Cannot declare class PHPUnit_Framework_Assert, because the name is already in use in /Users/<me>/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/shim.php on line 17
Call Stack:
0.0003 373480 1. {main}() /Users/<me>/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/codecept:0
0.0005 401560 2. require_once('/Users/<me>/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/autoload.php') /Users/michaelutz/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/codecept:7
0.0087 1765936 3. include_once('/Users/<me>/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/shim.php') /Users/michaelutz/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/autoload.php:45
0.0103 2021592 4. class_alias() /Users/<me>/Code/theutz/advanced-custom-enums/vendor/codeception/codeception/shim.php:17
Are you using the latest Codeception\Verify? This hit me earlier as well, it's caused by https://github.com/Codeception/Verify/pull/31 - for now, I've set my Verify version to 0.3.3.
The problem comes from https://github.com/Codeception/Codeception/blob/2.3/shim.php#L16 - Codeception only checks if (!class_exists('PHPUnit_Framework_TestCase') && class_exists('PHPUnit\Framework\TestCase')) however, it creates aliases for all PHPUnit 6 classes used by Codeception. In Verify, an alias is defined for PHPUnit_Framework_Assert:
https://github.com/Codeception/Verify/blob/master/src/Codeception/function.php#L2
In my opinion, either all classes in the shim file should be checked before aliased, or at least the ones aliased in Verify so the two libraries work together. Apparently Verify is used without Codeception (and the PR fixed an issue in such case). Funnily, that fix breaks Codeception.
Edit: I've decided to make a PR to try to get this somewhere.
I've actually run into the same problem. In my case the Codeception tests are included in a phing build process and this issue causes the build to fail.
Gladly the fix mentioned by @ddinchev - setting the Verify version to 0.3.3 - works fine for me. But I agree that all classes should be checked before creating an alias for them in the shim file.
Most helpful comment
Are you using the latest
Codeception\Verify? This hit me earlier as well, it's caused by https://github.com/Codeception/Verify/pull/31 - for now, I've set myVerifyversion to0.3.3.The problem comes from https://github.com/Codeception/Codeception/blob/2.3/shim.php#L16 - Codeception only checks
if (!class_exists('PHPUnit_Framework_TestCase') && class_exists('PHPUnit\Framework\TestCase'))however, it creates aliases for all PHPUnit 6 classes used by Codeception. In Verify, an alias is defined forPHPUnit_Framework_Assert:https://github.com/Codeception/Verify/blob/master/src/Codeception/function.php#L2
In my opinion, either all classes in the shim file should be checked before aliased, or at least the ones aliased in
Verifyso the two libraries work together. ApparentlyVerifyis used withoutCodeception(and the PR fixed an issue in such case). Funnily, that fix breaksCodeception.Edit: I've decided to make a PR to try to get this somewhere.