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.

CommentFileSizeAuthor
#2 examples-no-t-test-assertions-7.patch56.06 KBjhodgdon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Assigned: Unassigned » jhodgdon

I am working on a patch for this.

jhodgdon’s picture

Status: Active » Needs review
FileSize
56.06 KB

Here'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...

jhodgdon’s picture

Ah, 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.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Looks great!

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the review... I guess I can commit this. Done!

rfay’s picture

Thanks! That went by fast. And such a good thing. That was always so silly having t() in there.

Mile23’s picture

The 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.

jhodgdon’s picture

The XSS or SSS argument does not apply to test assertions. They are not using any outside input.

Mile23’s picture

Was a joke. :-)

rfay’s picture

But those SSS attacks are the up and coming thing. Got to be careful.

Status: Fixed » Closed (fixed)

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