ListFieldUITestCase::testListAllowedValuesBoolean

7 list.test ListFieldUITestCase::testListAllowedValuesBoolean()
8 list.test ListFieldUITestCase::testListAllowedValuesBoolean()

List (boolen) : test 'On/Off' values input.

File

modules/field/modules/list/tests/list.test, line 385
Tests for list.module.

Code

function testListAllowedValuesBoolean() {
  $this->field_name = 'field_list_boolean';
  $this->createListField('list_boolean');

  // Check that the separate 'On' and 'Off' form fields work.
  $on = $this->randomName();
  $off = $this->randomName();
  $allowed_values = array(
    1 => $on,
    0 => $off,
  );
  $edit = array(
    'on' => $on, 
    'off' => $off,
  );
  $this->drupalPost($this->admin_path, $edit, t('Save settings'));
  $this->assertText("Saved field_list_boolean configuration.", t("The 'On' and 'Off' form fields work for boolean fields."));
  // Test the allowed_values on the field settings form.
  $this->drupalGet($this->admin_path);
  $this->assertFieldByName('on', $on, t("The 'On' value is stored correctly."));
  $this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly."));
  $field = field_info_field($this->field_name);
  $this->assertEqual($field['settings']['allowed_values'], $allowed_values, t('The allowed value is correct'));
  $this->assertFalse(isset($field['settings']['on']), t('The on value is not saved into settings'));
  $this->assertFalse(isset($field['settings']['off']), t('The off value is not saved into settings'));
}
Login or register to post comments