Convert `@group foo` to `#[Group(…)]` + other annotations — to restore the ability to run a subset of Canvas' test suite, enforce it using PHPCS
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3574687. -->
Reported by: [wim leers](https://www.drupal.org/user/99777)
Related to !654
>>>
<h3 id="overview">Overview</h3>
<p>Specifying <code> _PHPUNIT_EXTRA=--group JavaScriptComponents</code> no longer works:</p>
<pre>executing: sudo -u www-data -H -E /builds/project/canvas/vendor/bin/phpunit --bootstrap /builds/project/canvas/web/core/tests/bootstrap.php /builds/project/canvas/web/modules/custom/canvas --log-junit /builds/project/canvas/junit.xml --group JavaScriptComponents<br>PHPUnit 11.5.55 by Sebastian Bergmann and contributors.<br>Runtime: PHP 8.3.30<br>Configuration: /builds/project/canvas/phpunit.xml<br>No tests executed</pre><p>
— <a href="https://git.drupalcode.org/project/canvas/-/jobs/8571568#L452">https://git.drupalcode.org/project/canvas/-/jobs/8571568#L452</a></p>
<p><strong>That did not find any tests to run at all! 🤯</strong></p>
<p>Running PHPUnit locally confirms this:</p>
<pre>$ vendor/bin/phpunit --bootstrap core/tests/bootstrap.php modules/contrib/experience_builder --list-groups<br>PHPUnit 11.5.53 by Sebastian Bergmann and contributors.<br><br>Available test groups:<br> - canvas (612 tests)<br> - canvas. (3 tests)<br> - canvas_ai (50 tests)<br> - canvas_component_sources (74 tests)<br> - canvas_component_sources__js (3 tests)<br> - canvas_data_model (192 tests)<br> - canvas_data_model__prop_expressions (157 tests)<br> - canvas_oauth (82 tests)<br> - canvas_personalization (82 tests)<br> - default (790 tests)<br> - default_content_api (1 test)<br> - legacy (10 tests)</pre><p>As does <code>php core/scripts/run-tests.sh modules/contrib/experience_builder/ --list --phpunit-configuration core/phpunit.xml</code>.</p>
<p><strong>Turns out this is due to changes in PHPUnit.</strong></p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p>Convert <em>every</em> occurrence of <code>@group \w+</code> in the Canvas codebase:<br>
<img src="https://www.drupal.org/files/issues/2026-02-19/Screenshot%202026-02-19%20at%2010.25.55%E2%80%AFPM.png"></p>
<p>Note that we must convert ALL <code>@something</code> annotations that PHPUnit uses to attributes. Use the script in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-6"><a href="https://www.drupal.org/project/drupal/issues/3446380" title="Status: Closed (works as designed)">#3446380: [no-commit] Define a Rector rule to convert test annotations to attributes</a></span> to avoid having to do this by hand.</p>
<p><strong>This will once again enable us to run a subset of the test suite now that PHPUnit 11 is used.</strong> Core CR: <a href="https://www.drupal.org/node/3447698">https://www.drupal.org/node/3447698</a></p>
<h3 id="ui-changes">User interface changes</h3>
<p>None.</p>
> Related issue: [Issue #3497431](https://www.drupal.org/node/3497431)
> Related issue: [Issue #3446380](https://www.drupal.org/node/3446380)
issue