Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There is no need to use t() in tests, unless we're testing translations, however in core we do not follow this consistently, which does not set a good example for new contributions.
#3153468: Strip HTML tags when using assertEquals() to compare markup exists to deal with some tricky cases in assertEquals()
calls.
If we ignore those then there are just under 300 cases remaining across core:
$ find core -type f -iname '*Test.php' | xargs grep '[^a-zA-Z]t(' | grep -v assertEqual | wc -l
279
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3231781
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 #3
longwaveAbout halfway done.
Comment #4
longwaveRemaining cases are:
Otherwise I think this is done.
Comment #5
longwaveComment #7
longwaveThanks for fixing that :)
Comment #8
mondrakeThis is close. Please see a few comments on the MR.
@core committers please see @TR's request for crediting people in the peer issue #2552067-50: Remove t() from assertion messages in tests.
Comment #9
longwaveThanks for reviewing, feedback addressed.
Comment #10
mondrakeThanks
Comment #19
larowlanAdding credit per remaining tasks
Comment #20
larowlanCrediting @mondrake for reviewing
Comment #21
larowlanGetting a second opinion as to whether this needs to wait for a disruptive patch window.
Reviewed the diff and it looks good to me, thanks for using an MR here, the word-diff formatting in gitlab was much easier to review than it would have been with dreditor.
Comment #22
mondrakeRerolled
Comment #23
alexpottI think we should go for a disruptive window here because the MR doesn't apply to 9.2.x as well. If we could apply it there we could say this isn't going to make security releases harder but it will so let's apply during the 9.3.x beta.
Comment #24
mondrakeRerolled
Comment #25
mondrakeComment #26
longwaveBumping for visibility, patch still applies cleanly for me.
Comment #27
TR CreditAttribution: TR commentedI agree it applies cleanly and fixes a whole lot of problems and should be committed soon.
There are a few cases that the regexp in the summary misses, but I think those are exceptions and should be handled in a clean-up issue. For example, in FileTestBase there are two blocks of code like this:
This is missed because the message is a variable rather than an in-line use of t().
But again, I don't want to derail this patch just because of a small number of things like this - what's in this patch is good and appropriate and correct. I would rather add a new child issue in the meta to handle any exceptions like this.
Comment #29
larowlanCommitted a83a7a7 and pushed to 9.4.x. Thanks!
To maximize the chance of future backports applying cleanly, backported to 9.3.x
Nice work all.
Comment #31
mondrakeI think the idea was to port it down to 9.2.x to alleviate potential efforts with security patches? Otherwise I do not see much sense to wait for 'disruptive patch windows'
Comment #32
larowlan9.2 has had its last bugfix release, any security release would be on top of that tag, so backporting to 9.2.x HEAD won't help security patches apply cleaner unfortunately