I'm just starting to get into PHPUnit testing and when I try to run "phpunit --list-groups" on the 8.5-dev/stable branches I get the following error:
"PHP Fatal error: Cannot use Drupal\Tests\entity_test\Functional\Rest\EntityTestResourceTestBase as EntityTestResourceTestBase because the name is already in use in /var/www/drupal_test/dev/web/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestTextItemNormalizerTest.php on line 8"
To replicate:
- Spin up the latest version of Drupal (either dev 8.5.5-dev or stable 8.5.4)
- Run "vendor/bin/phpunit --list-groups" in core
- Get fatal error
I believe this is because the "EntityTestTextItemNormalizerTest.php" is trying to use the "EntityTestResourceTestBase" class and not using an alias, when there is already the same class existing in its' own namespace, so I've copied the alias that the other file is using.
I can see that "EntityTestTextItemNormalizerTest.php" looks like it is removed in the 8.6.x branch, however at the moment this is causing me issues so I'll submit a patch in case anybody is having the same issue!
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2979925-8.patch | 6.17 KB | Anonymous (not verified) |
| #5 | 2979925-fix-name-conflict-for-rest-entitytestresourcetestbase.patch | 1.03 KB | littlepixiez |
Comments
Comment #2
littlepixiez commentedComment #3
littlepixiez commentedComment #5
littlepixiez commentedAh, my bad - I did the patch in the core directory. This is all very new to me - hopefully should now pass.
Comment #6
littlepixiez commentedComment #7
borisson_I'm not sure, it is a good idea because it causes failures, but I'm not sure that we should be committing this, as 8.6 will be released in september.
This is probably something that the committers will know more about - if we should commit this. It does fix the problem in a good way. Leaving this issue on needs review to wait for committer/other feedback
Comment #8
Anonymous (not verified) commentedI'm the developer who is to blame for this problem :)
EntityTestTextItemNormalizerTestis really obstinate! It was not processed by the script for 8.6.x, as result it required an additional patch #2910883-70: Move all entity type REST tests to the providing modules. And it was only half done for 8.5.x 😪We need just remove
core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestTextItemNormalizerTest.php, because the actual test lives in thecore/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.phpHowever.. I cann't reproduce problem by IS replicate steps for latest 8.5.x. Run
"../vendor/bin/phpunit" --list-groupsfrom core folder shows all 221 groups without error. I use php7 and phpunit 6.5.In any case, @littlepixiez++!
Also thanks to @borisson_ for highlighting this issue.
Comment #9
littlepixiez commentedHey @borisson_, I wasn't sure whether it was a big issue or not as I saw that it was going to get resolved later on!
And @vaplas, I've just tested the original issue against PHP 7.0 and no error occurs - it looks like it only happens with PHP 5.6 which we're using. I guess PHP 7.0 must be less strict about it! Thanks very much for the patch, that's great. :D
Comment #10
wim leersThank you very much for creating this issue @littlepixiez!
Comment #11
alexpott8.5.x is now closed for normal bugfixes and this is fixed in 8.7.x/8.6.x so there's no need to fix.
Thanks for filing the issue though! Sorry we didn't get to this before the 8.5.x went to critical only.
Comment #12
damienmckennaWhile I respect the maintainers' decision to control what goes into each branch, might this not cause problems for contrib tests?