You are here

public function RangeInternationalizationWebTestCase::testRangeFieldWidgetRespectsInterfaceLanguage in Range 7

Verifies that range module field widget respects interface language.

File

tests/range.i18n.test, line 223
Contains range i18n tests.

Class

RangeInternationalizationWebTestCase
Tests translatability of range fields.

Code

public function testRangeFieldWidgetRespectsInterfaceLanguage() {
  $account = $this
    ->drupalCreateUser(array(
    'administer content types',
    'administer nodes',
    "create {$this->contentType} content",
  ));
  $this
    ->drupalLogin($account);

  // Translate field instance settings.
  $this
    ->translateRangeFieldInstanceSettings();
  $languages = language_list();

  // Test default language (field instance settings should be in the original
  // language - English).
  $this
    ->drupalGet("node/add/{$this->contentType}", array(
    'language' => $languages[static::PRIMARY_LANGUAGE],
  ));

  // Test field widget form.
  $this
    ->assertFieldLabel(static::INSTANCE_SETTINGS_FROM_LABEL, format_string('Correct original field label %label found on the page', array(
    '%label' => static::INSTANCE_SETTINGS_FROM_LABEL,
  )));
  $this
    ->assertFieldLabel(static::INSTANCE_SETTINGS_TO_LABEL, format_string('Correct original field label %label found on the page', array(
    '%label' => static::INSTANCE_SETTINGS_TO_LABEL,
  )));
  $this
    ->assertFieldPrefix(static::INSTANCE_SETTINGS_FIELD_PREFIX . static::INSTANCE_SETTINGS_FROM_PREFIX, format_string('Correct original field prefix %prefix found on the page', array(
    '%prefix' => static::INSTANCE_SETTINGS_FIELD_PREFIX . static::INSTANCE_SETTINGS_FROM_PREFIX,
  )));
  $this
    ->assertFieldSuffix(static::INSTANCE_SETTINGS_FROM_SUFFIX, format_string('Correct original field suffix %suffix found on the page', array(
    '%suffix' => static::INSTANCE_SETTINGS_FROM_SUFFIX,
  )));
  $this
    ->assertFieldPrefix(static::INSTANCE_SETTINGS_TO_PREFIX, format_string('Correct original field prefix %prefix found on the page', array(
    '%prefix' => static::INSTANCE_SETTINGS_TO_PREFIX,
  )));
  $this
    ->assertFieldSuffix(static::INSTANCE_SETTINGS_TO_SUFFIX . static::INSTANCE_SETTINGS_FIELD_SUFFIX, format_string('Correct original field suffix %suffix found on the page', array(
    '%suffix' => static::INSTANCE_SETTINGS_TO_SUFFIX . static::INSTANCE_SETTINGS_FIELD_SUFFIX,
  )));

  // Test secondary language (field instance settings should be translated to
  // the secondary language).
  $this
    ->drupalGet("node/add/{$this->contentType}", array(
    'language' => $languages[static::SECONDARY_LANGUAGE],
  ));
  $this
    ->assertFieldLabel(static::INSTANCE_SETTINGS_FROM_LABEL_TRANSLATED, format_string('Correct translated field label %label found on the page', array(
    '%label' => static::INSTANCE_SETTINGS_FROM_LABEL_TRANSLATED,
  )));
  $this
    ->assertFieldLabel(static::INSTANCE_SETTINGS_TO_LABEL_TRANSLATED, format_string('Correct translated field label %label found on the page', array(
    '%label' => static::INSTANCE_SETTINGS_TO_LABEL_TRANSLATED,
  )));
  $this
    ->assertFieldPrefix(static::INSTANCE_SETTINGS_FIELD_PREFIX_TRANSLATED . static::INSTANCE_SETTINGS_FROM_PREFIX_TRANSLATED, format_string('Correct translated field prefix %prefix found on the page', array(
    '%prefix' => static::INSTANCE_SETTINGS_FIELD_PREFIX_TRANSLATED . static::INSTANCE_SETTINGS_FROM_PREFIX_TRANSLATED,
  )));
  $this
    ->assertFieldSuffix(static::INSTANCE_SETTINGS_FROM_SUFFIX_TRANSLATED, format_string('Correct translated field suffix %suffix found on the page', array(
    '%suffix' => static::INSTANCE_SETTINGS_FROM_SUFFIX_TRANSLATED,
  )));
  $this
    ->assertFieldPrefix(static::INSTANCE_SETTINGS_TO_PREFIX_TRANSLATED, format_string('Correct translated field prefix %prefix found on the page', array(
    '%prefix' => static::INSTANCE_SETTINGS_TO_PREFIX_TRANSLATED,
  )));
  $this
    ->assertFieldSuffix(static::INSTANCE_SETTINGS_TO_SUFFIX_TRANSLATED . static::INSTANCE_SETTINGS_FIELD_SUFFIX_TRANSLATED, format_string('Correct translated field suffix %suffix found on the page', array(
    '%suffix' => static::INSTANCE_SETTINGS_TO_SUFFIX_TRANSLATED . static::INSTANCE_SETTINGS_FIELD_SUFFIX_TRANSLATED,
  )));
}