I want to remove t() from all the documented example code in BrowserTestBase.
This best describes why.
https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial
When to use t() in browser tests
Never! Nope, not in assertion messages, not for button labels, not for text you assert on the page. You always want to test the literal string on the page, you don't want to test the Drupal translation system.
------
It is too big a job to remove t('example') from our code ... it will go away slowly in years to come.
But we should stop documenting it in our examples now.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | charm-2875148-9.patch | 3 KB | martin107 |
| #9 | interdiff-2875148-9.txt | 2.49 KB | martin107 |
| #9 | charm-2875148-9.txt | 3 KB | martin107 |
Comments
Comment #2
martin107 commentedMy fellow Bostonians, I humbly suggest the first step is for us to throw the tea in the harbour.
Comment #3
martin107 commentedComment #4
dawehnerMaybe we should explitely mention to not use the t() function, what do you think?
Comment #5
martin107 commentedI agree, added at the top of the class.
PS made issue summary more readable.
Comment #6
dawehnerThank you @martin107!
Comment #7
martin107 commentedComment #8
alexpottI think we should say something like
Tests extending this base class should only translate text when testing translation functionality. For example, avoid wrapping test text with t() or TranslatableMarkup().Since t() is deprecated and on the way out.
These comments can re-flowed
Comment #9
martin107 commented8.1) Sure, adopting a more informative tone, is better.
8.2) Reflowed.
Comment #10
martin107 commentedI knew making quark jokes would get me into trouble.
Comment #12
borisson_This patch still applies, it's a great idea to improve this documentation. It changed the changes requested in #8.
Comment #14
catchCommitted/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!
Comment #16
mile23Anyone want to improve Examples on this? #2924223: Remove t() from tests