Part of #500866: [META] remove t() from assert message
Follow-up to #1803674: Remove t() from default test assertions in TestBase class

The WebTestBase class should not contain calls to t() for format_plural().

All t() calls should be replaced with String::format().

Plain text strings without token replacements can be output directly.

Calls to format_plural() are to be replaced with English plural rules, which means this:

- $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
+ $message = $emailCount == 1 ? '1 e-mail was sent during this test.' : $emailCount . ' e-mails were sent during this test.';
CommentFileSizeAuthor
#2 drupal-2195623-2.patch19.75 KBolli
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Issue tags: +Novice

Possibly this would be a good Novice project, for a motivated novice? Or non-novice. Either way. :)

olli’s picture

Status: Active » Needs review
FileSize
19.75 KB
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

This patch was very carefully done. I checked it over carefully, and am reasonably certain it is removing t() from the right places, and leaving it in where I believe we still want it (such as translating the submit button text in code like this:

    $this->drupalPostForm('user', $edit, t('Log in'));

I also verified there are no format_plural() calls in WebTestBase, and that it caught everything.

I especially love the irony that there were all these documentation comments in WebTestBase:

   *   (optional) A message to display with the assertion. Do not translate
   *   messages: use format_string() to embed variables in the message text, not
   *   t(). If left blank, a default message will be displayed.

followed just a few lines later by the default message being translated with t(). Um. :)

Great job on the patch!

sun’s picture

Thanks, this looks great.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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