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!

Comments

littlepixiez created an issue. See original summary.

littlepixiez’s picture

Issue summary: View changes
littlepixiez’s picture

Status: Active » Needs review

Status: Needs review » Needs work
littlepixiez’s picture

StatusFileSize
new1.03 KB

Ah, my bad - I did the patch in the core directory. This is all very new to me - hopefully should now pass.

littlepixiez’s picture

Status: Needs work » Needs review
borisson_’s picture

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

Anonymous’s picture

StatusFileSize
new6.17 KB

I'm the developer who is to blame for this problem :)

EntityTestTextItemNormalizerTest is 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 the core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php

However.. I cann't reproduce problem by IS replicate steps for latest 8.5.x. Run "../vendor/bin/phpunit" --list-groups from 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.

littlepixiez’s picture

Hey @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

wim leers’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +API-First Initiative

Thank you very much for creating this issue @littlepixiez!

alexpott’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

8.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.

damienmckenna’s picture

While I respect the maintainers' decision to control what goes into each branch, might this not cause problems for contrib tests?