Closed (won't fix)
Project:
Drupal core
Version:
11.x-dev
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 May 2024 at 13:13 UTC
Updated:
9 May 2024 at 20:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mondrakeOut of curiosity I tried run Rector with this config
and it produced the attached patch; it's not perfect but it should fix 95% of the cases. A bit annoying the added
useimport is not sorted alphabeticalyl, but I assume some PHPCS magic could happen to fix that as well.Comment #3
mstrelan commentedI think we can continue with this now that #3417066: Upgrade PHPUnit to 10, drop Symfony PHPUnit-bridge dependency is in. The patch looks like a great start!
There is
SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses, but see #1624564: Coding standards for "use" statements where it's being discussed as a coding standard.Comment #4
mstrelan commentedI think we should also add
@dataProviderto theSlevomatCodingStandard.Commenting.ForbiddenAnnotationsconfiguration in phpcs.xml.distComment #5
mondrakeComment #6
longwaveAs spotted over in #3417066-120: Upgrade PHPUnit to 10, drop Symfony PHPUnit-bridge dependency, it looks like we can't mix PHPUnit attributes and annotations, we will have to convert them all at once unfortunately:
Comment #7
mondrake#6 - ouch that's painful.. however we could keep annotations as well as attributes in the same test file, so for BC to have PHPUnit 9 compatiblity (using annotations) and PHPUnit 10/11 compatibility (using attributes) at the same time. See for example these tests in a library I maintain on GitHub: https://github.com/FileEye/MimeMap/blob/ba0b04e179976e7d6a487fdb166c5f1f...
However, we can't proceed by annotation. Do we need an issue to build a comprehensive Rector that would address all annotations and then use that to proceed by test suite/core-module?
Comment #8
solideogloria commentedI think having some issue open would be good. I just found this issue after reading about the availability of attributes
https://docs.phpunit.de/en/10.5/writing-tests-for-phpunit.html#data-prov...
Comment #9
mondrakeFiled #3446380: [no-commit] Define a Rector rule to convert test annotations to attributes. See you there!