You are here

protected function RangeFieldUIWebTestCase::_testRangeFieldInstanceSettingsUI in Range 7

Helper method. Sets range field instance settings via field UI.

Parameters

string $field_type: Range field type. Could be one of the following values: range_integer, range_float or range_decimal.

1 call to RangeFieldUIWebTestCase::_testRangeFieldInstanceSettingsUI()
RangeFieldUIWebTestCase::_testRangeFieldUI in tests/range.field_ui.test
Helper method. Tests given range field type via field UI.

File

tests/range.field_ui.test, line 135
Contains range field UI tests.

Class

RangeFieldUIWebTestCase
Tests adding range fields and their settings via field UI.

Code

protected function _testRangeFieldInstanceSettingsUI($field_type = 'range_integer') {
  $field_name = $this
    ->getTestFieldName($field_type);
  switch ($field_type) {
    case 'range_integer':
    case 'range_float':
    case 'range_decimal':
      $edit = array(
        'instance[settings][min]' => static::INSTANCE_SETTINGS_MIN,
        'instance[settings][max]' => static::INSTANCE_SETTINGS_MAX,
        'instance[settings][field][prefix]' => static::INSTANCE_SETTINGS_FIELD_PREFIX,
        'instance[settings][field][suffix]' => static::INSTANCE_SETTINGS_FIELD_SUFFIX,
        'instance[settings][from][label]' => static::INSTANCE_SETTINGS_FROM_LABEL,
        'instance[settings][from][prefix]' => static::INSTANCE_SETTINGS_FROM_PREFIX,
        'instance[settings][from][suffix]' => static::INSTANCE_SETTINGS_FROM_SUFFIX,
        'instance[settings][to][label]' => static::INSTANCE_SETTINGS_TO_LABEL,
        'instance[settings][to][prefix]' => static::INSTANCE_SETTINGS_TO_PREFIX,
        'instance[settings][to][suffix]' => static::INSTANCE_SETTINGS_TO_SUFFIX,
        'instance[settings][combined][prefix]' => static::INSTANCE_SETTINGS_COMBINED_PREFIX,
        'instance[settings][combined][suffix]' => static::INSTANCE_SETTINGS_COMBINED_SUFFIX,
      );
      break;
    default:
      $edit = array();
  }

  // Save field instance settings via field UI.
  $this
    ->drupalPost(NULL, $edit, t('Save settings'));

  // Clear field info cache.
  field_info_cache_clear();

  // Ensure that all field instance settings were saved correctly.
  $field = field_info_field($field_name);
  $instance = field_info_instance('node', $field_name, $this->contentType);
  $settings = $instance['settings'];
  $this
    ->assertEqual($settings['min'], static::INSTANCE_SETTINGS_MIN, format_string('Correct minimum setting %value found for the %field_type field type', array(
    '%value' => $settings['min'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['max'], static::INSTANCE_SETTINGS_MAX, format_string('Correct maximum setting %value found for the %field_type field type', array(
    '%value' => $settings['max'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['field']['prefix'], static::INSTANCE_SETTINGS_FIELD_PREFIX, format_string('Correct FIELD prefix setting %value found for the %field_type field type', array(
    '%value' => $settings['field']['prefix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['field']['suffix'], static::INSTANCE_SETTINGS_FIELD_SUFFIX, format_string('Correct FIELD suffix setting %value found for the %field_type field type', array(
    '%value' => $settings['field']['suffix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['from']['label'], static::INSTANCE_SETTINGS_FROM_LABEL, format_string('Correct FROM label setting %value found for the %field_type field type', array(
    '%value' => $settings['from']['label'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['from']['prefix'], static::INSTANCE_SETTINGS_FROM_PREFIX, format_string('Correct FROM prefix setting %value found for the %field_type field type', array(
    '%value' => $settings['from']['prefix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['from']['suffix'], static::INSTANCE_SETTINGS_FROM_SUFFIX, format_string('Correct FROM suffix setting %value found for the %field_type field type', array(
    '%value' => $settings['from']['suffix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['to']['label'], static::INSTANCE_SETTINGS_TO_LABEL, format_string('Correct TO label setting %value found for the %field_type field type', array(
    '%value' => $settings['to']['label'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['to']['prefix'], static::INSTANCE_SETTINGS_TO_PREFIX, format_string('Correct TO prefix setting %value found for the %field_type field type', array(
    '%value' => $settings['to']['prefix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['to']['suffix'], static::INSTANCE_SETTINGS_TO_SUFFIX, format_string('Correct TO suffix setting %value found for the %field_type field type', array(
    '%value' => $settings['to']['suffix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['combined']['prefix'], static::INSTANCE_SETTINGS_COMBINED_PREFIX, format_string('Correct COMBINED prefix setting %value found for the %field_type field type', array(
    '%value' => $settings['combined']['prefix'],
    '%field_type' => $field['type'],
  )));
  $this
    ->assertEqual($settings['combined']['suffix'], static::INSTANCE_SETTINGS_COMBINED_SUFFIX, format_string('Correct COMBINED suffix setting %value found for the %field_type field type', array(
    '%value' => $settings['combined']['suffix'],
    '%field_type' => $field['type'],
  )));
}