We're in the midst of a big clean-up effort in Core 7/8 to remove t() from test assertion messages:
#500866: [META] remove t() from assert message
#1457320: Document that t() should not be used for assertion message texts and groups
It seems that at least some of the test assertions in the Examples project still have t() on assert messages, and in order to be good examples, they shouldn't.
http://drupal.org/simpletest-tutorial-drupal7#t
For example, in action_example.test:
$this->assertTrue($normal_user->status, t('Normal user status has been set to unblocked'));
should be:
$this->assertTrue($normal_user->status, 'Normal user status has been set to unblocked');
There may not be too many problems of this nature... for example, node_example.test looks to be clean... but there are at least some.
Comment | File | Size | Author |
---|---|---|---|
#2 | examples-no-t-test-assertions-7.patch | 56.06 KB | jhodgdon |
Comments
Comment #1
jhodgdonI am working on a patch for this.
Comment #2
jhodgdonHere's a patch for the D7 version. I am not sure if you are working on d8 examples actively, so I didn't look at them yet...
Comment #3
jhodgdonAh, I see from the Examples home page that d8 is not being worked on. Looks like the tests passed... I'll see if I can find one of the people who's been reviewing the corresponding core issues to give it a once-over review.
Comment #4
tstoecklerLooks great!
Comment #5
jhodgdonThanks for the review... I guess I can commit this. Done!
Comment #6
rfayThanks! That went by fast. And such a good thing. That was always so silly having t() in there.
Comment #7
Mile23The main advantage of t() being: You get check_plain() for free. You never know what sort of SSS (Same-Site Scripting) attack you might be running on yourself.
Comment #8
jhodgdonThe XSS or SSS argument does not apply to test assertions. They are not using any outside input.
Comment #9
Mile23Was a joke. :-)
Comment #10
rfayBut those SSS attacks are the up and coming thing. Got to be careful.