1 field_ui.test FieldUIManageFieldsTestCase::createField()

Tests adding a new field.

@todo Assert properties can bet set in the form and read back in $field and $instances.

File

core/modules/field_ui/tests/field_ui.test, line 243
Tests for field_ui.module.

Class

FieldUIManageFieldsTestCase
Tests the functionality of the 'Manage fields' screen.

Code

function createField() {
  // Create a test field.
  $edit = array(
    'fields[_add_new_field][label]' => $this->field_label,
    'fields[_add_new_field][field_name]' => $this->field_name_input,
  );
  $this->fieldUIAddNewField('admin/structure/types/manage/' . $this->hyphen_type, $edit);

  // Assert the field appears in the "add existing field" section for
  // different entity types; e.g. if a field was added in a node entity, it
  // should also appear in the 'taxonomy term' entity.
  $this->backdropGet('admin/structure/taxonomy/tags/fields');
  $this->assertTrue($this->xpath('//select[@name="fields[_add_existing_field][field_name]"]//option[@value="' . $this->field_name . '"]'), 'Existing field was found in term settings.');
}