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.

In #3133726: [meta] Remove usage of t() in tests not testing translation we identified there are severals of calls to t() in calls to assertEqual() and assertEquals() and that removing all these in one go seems to be a suitable way of attacking this problem.

Proposed resolution

Identify and remove all calls to t() wrapped in calls to assertEquals() where:

  • the message is a plain string that doesn't use placeholders - here t() can be removed
  • the message is used as the $message argument in the assertion - here the entire argument can usually be removed

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3226008

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

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review

First pass at this. I thought about removing new FormattableMarkup() here as well but then remembered #2549805: [Meta] Remove all usage of FormattableMarkup in tests apart from explicit tests of that API, I think this should only cover t().

mondrake’s picture

Status: Needs review » Needs work

Nice. A few things can be improved, two changes that overlap with #3220255: Convert assertions involving use of xpath on links to WebAssert

longwave’s picture

Status: Needs work » Needs review

Thanks for the review. I fixed those and took the opportunity to improve some other assertions here as well.

mondrake’s picture

Status: Needs review » Needs work
longwave’s picture

Status: Needs work » Needs review
mondrake’s picture

Status: Needs review » Needs work

Few more comments.

longwave’s picture

Status: Needs work » Needs review

Fixed two, disagreed with one :)

longwave’s picture

Improved the "Place block" case over at #3038594: WebAssert should return the found links

mondrake’s picture

Thanks. LGTM now. Overlaps with #3220255: Convert assertions involving use of xpath on links to WebAssert so whatever goes in first will require the reroll of the other.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community
mondrake’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Merged 9.3.x.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Back to Rtbc

catch’s picture

Title: Remove simple uses of t() in assertEquals() calls » [backport] Remove simple uses of t() in assertEquals() calls
Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Committed/pushed to 9.3.x, thanks!

Needs a re-roll for 9.2.x.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

Not pushed.

longwave’s picture

Title: [backport] Remove simple uses of t() in assertEquals() calls » Remove simple uses of t() in assertEquals() calls
Version: 9.2.x-dev » 9.3.x-dev
Issue tags: -Needs reroll

Restoring old metadata until 9.3.x is pushed.

  • catch committed 0aed129 on 9.3.x
    Issue #3226008 by longwave, mondrake: Remove simple uses of t() in...
longwave’s picture

Title: Remove simple uses of t() in assertEquals() calls » [backport] Remove simple uses of t() in assertEquals() calls
Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

longwave’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Rerolled, one conflict in DownloadTest where file_create_url() is $this->fileUrlGenerator->generateString() in 9.3.x

  • catch committed c4d7857 on 9.2.x
    Issue #3226008 by longwave, mondrake: Remove simple uses of t() in...
catch’s picture

Title: [backport] Remove simple uses of t() in assertEquals() calls » Remove simple uses of t() in assertEquals() calls
Status: Reviewed & tested by the community » Fixed

Committed c4d7857 and pushed to 9.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.