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 over 100 cases remaining in assertions, which seems suitable to deal with all in one go:
$ rg 'assert.*\Wt\(' core|grep -v assertEqual|wc -l
108
Steps to reproduce
Proposed resolution
Search for calls to t() in tests using the above regex and remove t() and/or replace the assertion with something more appropriate.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3227501
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
longwaveComment #4
longwaveStarted but didn't finish.
Comment #5
longwaveRemaining cases are translation tests and MenuUiContentModerationTest where it is checking for a specific link embedded in a message and the t() version is significantly easier to read, to me anyway.
Comment #6
mondrakeA few possible improvements, see comments in the MR
Comment #7
longwaveThanks for reviewing, feedback addressed (and added two more replacements of
Link::fromTextAndUrl()
in UpdateContribTest).Comment #8
mondrakeThanks, looks good to me.
Comment #9
catchCommitted/pushed to 9.3.x, thanks!
Comment #11
catchDoesn't cherry-pick to 9.2.x. While this touches a few files, it's not that much in each file, so we can probably survive without the backport - however would commit one if someone does one.
Comment #12
longwaveIt will be easier to backport if #3139409: Replace usages of AssertLegacyTrait::assertRaw, that is deprecated gets in, as most of the conflicts are related to
assertRaw()
.Comment #13
longwaveComment #15
xjmToo late for 9.2.x now. :)