Problem/Motivation
Since PHPUnit 13.4, a number of tests are failing with a PHPUnit test runner deprecation
Class-level #[Group] attribute on Drupal\Tests\Core\Routing\UrlGeneratorTest is ignored, but will be inherited by its subclasses in PHPUnit 14
PHPUnit 13 src/Metadata/Parser/AttributeParser.php has this comment:
/**
* In PHPUnit 14, the tests of a test class inherit the groups declared on
* its parent classes, and their size from the nearest class that declares
* one. An attribute on a parent class only triggers a deprecation when
* this would change the groups or the size of the tests of the test class,
* which is not the case when the test class itself declares the same
* groups and a size.
*
* The deprecation keeps the test file of such a test class from being
* skipped by the test index, which never skips a file that PHPUnit had
* something to say about while it was loaded.
*
* @param ReflectionClass<object> $class
*/which means that in order to prevent the deprecations, the value of the #[Group] attribute in subclasses of a concrete test class must be equal to the parent.
Steps to reproduce
Run tests under PHPUnit, see #3574681: [Nov 2026] Introduce support for PHPUnit 13.5.
Proposed resolution
Make the #[Group] attributes of tests that inherit from other tests equal to the parent's ones.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3629710
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mondrakeComment #4
mondrakeComment #5
smustgrave commentedThink I'm understanding some of the group changes but not the additions of the #slow ?
Comment #6
mondrake#5 can’t do without. Groups in child MUST be equal to those in parent. So either remove from both, or add to both.
Can’t say I really understand why, but that’s the food we’re given.
An alternative may be to introduce an attribute of our own instead of #[Group] for this purpose, but that’d be another issue.
Comment #7
mondrakeor, make abstract base test classes with no attributes and extend to concrete classes with attributes.