The translation function is not used consistently throughout SimpleTest. In some places strings are automatically translated, but not in others.

Not auto-translated

  • assert*([conditions], $message = "%s") - $message
  • get_info - values in returned array


  • drupalPost($path, $edit = array(), $submit) - $submit
  • clickLink($label, $index = 0) - $label

There may be other areas that I haven't listed, but we need to come to a consensus on how this should be done.


webchick’s picture

My two cents is SimpleTest shouldn't do /any/ magical t()ing behind the scenes. I should have to wrap my submit button name in t(), and if I forget to, my test has a bug in it. SimpleTest trying to be "nice" for me just results in my never knowing whether I'm double t()ing or not.

However, I swear I had this conversation with Rok one time and thought that he explained it's somewhat trickier than that.

webchick’s picture

Here are the weird cases I was able to find. Only other one was in locale.test, but that's probably expected.

  function drupalPost($path, $edit = array(), $submit) {
   $ret = $this->_browser->clickSubmit(t($submit))  || $this->_browser->clickSubmitById($submit) || $this->_browser->clickSubmitByName($submit) || $this->_browser->clickImageByName($submit);
    $this->assertTrue($ret, ' [browser] POST by click on ' . t($submit));

This one is interesting. Basically, it's calling all the random SimpleTest functions that mean "Click on a submit button." The one it's t()ing is looking for button text sopecifically, where the others are looking for various attributes on HTML tags.

However, I still maintain that it's a bug not to have this t()ed in your original test if you in fact mean "Click on the thing labeled blah." However, it's confusing that this function can actually take any one of those types of submit texts.

function clickLink($label, $index = 0) {
    $ret = parent::clickLink(t($label), $index);

    $this->assertTrue($ret, ' [browser] clicked link '. t($label) . " ($url_target) from $url_before");

This one can clearly go. It's just SimpleTest trying to safety net you. Don't safety net me. ;)

webchick’s picture

Status: Active » Needs work
3.81 KB

Here's a patch that gets rid of the clickLink auto-t(). I'm still a little torn on the drupalPost one, since it could result in unintended consequences if you're after the "edit" ID, and there's a button on your page somewhere else named "edit". I'm not sure if this is likely to happen often enough for it to be a concern, but...

webchick’s picture

Here's a re-roll after chx's browser patch went in.

webchick’s picture

Ok, looks like chx's patch also cleaned up the instance in drupalPost(), so that settles that. :)

However, now we need to make sure that the submit button names are t()ed properly in all the tests. Working on that now.

webchick’s picture

Status: Needs work » Needs review
87.94 KB

Ok here it is... drumroll...

This patch:
1. Removes auto-t()ing from clickLink
2. Makes all calls to clickLink('something') -> clickLink(t('something'))
3. Makes all calls to drupalPost(..., 'button') to drupal_Post(..., t('button'))
4. Fixes Windows line endings in trigger.test.

boombatower’s picture

Status: Needs review » Fixed


Looks great.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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