You are here

public function RulesI18nTestCase::testI18nActionSelect in Rules 7.2

Tests the "Select a translated value" action.

File

rules_i18n/rules_i18n.test, line 169
Rules i18n tests.

Class

RulesI18nTestCase
Test the i18n integration.

Code

public function testI18nActionSelect() {

  // Make the body field and the node type 'page' translatable.
  $field = field_info_field('body');
  $field['translatable'] = TRUE;
  field_update_field($field);
  variable_set('language_content_type_page', 1);
  $set = rules_action_set(array(
    'node' => array(
      'type' => 'node',
    ),
  ));
  $set
    ->action('rules_i18n_select', array(
    'data:select' => 'node:body:value',
    'language' => 'de',
    'data_translated:var' => 'body',
  ));
  $set
    ->action('drupal_message', array(
    'message:select' => 'body',
  ));
  $set
    ->save();
  $body['en'][0] = array(
    'value' => 'English body.',
  );
  $body['de'][0] = array(
    'value' => 'German body.',
  );
  $node = $this
    ->drupalCreateNode(array(
    'language' => 'en',
    'body' => $body,
  ));

  // Clear messages and execute it.
  drupal_get_messages();
  $set
    ->execute($node);
  $messages = drupal_get_messages();
  $this
    ->assertEqual($messages['status'][0], "German body.\n", 'Translated text has been selected.');
}