Problem/Motivation

In PHPUnit 12, we have to replace test annotations with attributes. As noticed in #3417066-120: Upgrade PHPUnit to 10, drop Symfony PHPUnit-bridge dependency,

we can't mix PHPUnit attributes and annotations [in a single file], we will have to convert them all at once unfortunately

with thousands of test classes in Drupal, we should try to automate the conversion, in a way that a script can be executed on a file and convert it end-to-end.

Rector can help, but we need an overall Rector script that will do all the changes necessary in a go - we should convert by files or group of files, and not by rule/annotation.

Listing some findings for the Rector rule, will document here along

Proposed resolution

The MR here contains the rector.php file with a custome rule to do the conversion, and a .gitlab-ci.yml CI configuration file with a script that executes the rector rule, then runs PBPCBF to cleanup the changed files, then produces a git diff patch file and finally stores the patch as an artifact.

The diff patch file can then be used in child issues to convert specific parts of the test codebase.

The MR itself is not meant to be committed.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#14 3446380-nr-bot.txt43.07 KBneeds-review-queue-bot

Issue fork drupal-3446380

Command icon 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

mondrake created an issue. See original summary.

mondrake’s picture

Issue summary: View changes
mondrake’s picture

mondrake’s picture

Currently developing a Rector script for this in https://github.com/mondrake/d8-unit/blob/test-rector/rector.php

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
Issue tags: +PHPUnit 12

Updated IS to clarify this is required in PHPUnit 12, not 11.

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Title: [meta] Define a Rector rule to convert test annotations to attributes » [no-commit] Define a Rector rule to convert test annotations to attributes

mondrake’s picture

Issue summary: View changes
Status: Active » Needs review
mondrake’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new43.07 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review
Issue tags: +no-needs-review-bot
mondrake’s picture

Status: Needs review » Active

'Active' is more appropriate as a status, maybe.

nicxvan’s picture

This could go into drupal rector too.

mondrake’s picture

Status: Active » Reviewed & tested by the community

This issue has completed its purpose as all bulk tests conversions were done.

I'd close this 'Closed (works as designed)' but I thought to set to RTBC first to see if any comments.

nicxvan’s picture

Can we open an issue in drupal rector with your rector script?

alexpott’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

As this has been marked RTBC for over a month going to mark as 'Closed (works as designed)'.

I opened #3552124: Leverage #3446380's rector rule to convert PHPUnit annotations to attributes

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.