function RulesI18nTestCase::testI18nActionT
Tests the "Translate a text" action.
File
-
rules_i18n/
rules_i18n.test, line 136
Class
- RulesI18nTestCase
- Test the i18n integration.
Code
public function testI18nActionT() {
$set = rules_action_set(array());
$set->action('rules_i18n_t', array(
'text' => 'untranslated',
'language' => 'de',
));
$set->action('drupal_message', array(
'message:select' => 'text',
));
$set->save('rules_i18n_test');
// Add a translation.
$actions = $set->getIterator();
$id = $actions[0]->elementId();
i18n_string_textgroup('rules')->update_translation("rules_config:{$set->name}:{$id}:text", 'de', 'text-de');
// Clear messages and execute it.
drupal_get_messages();
$set->execute();
$messages = drupal_get_messages();
$this->assertEqual($messages['status'][0], 'text-de', 'Text has been successfully translated.');
// Enable the PHP module and make sure PHP in translations is not evaluated.
module_enable(array(
'php',
));
i18n_string_textgroup('rules')->update_translation("rules_config:{$set->name}:{$id}:text", 'de', 'text <?php echo "eval";?>');
// Clear messages and execute it.
drupal_get_messages();
$set->execute();
$messages = drupal_get_messages();
$this->assertEqual($messages['status'][0], check_plain('text <?php echo "eval";?>'), 'PHP in translated text is not executed.');
}