You are here

function FieldUIManageFieldsTestCase::createField in Drupal 7

Tests adding a new field.

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

1 call to FieldUIManageFieldsTestCase::createField()
FieldUIManageFieldsTestCase::testCRUDFields in modules/field_ui/field_ui.test
Runs the field CRUD tests.

File

modules/field_ui/field_ui.test, line 198
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.
  $vocabulary = taxonomy_vocabulary_load(1);
  $this
    ->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/fields');
  $this
    ->assertTrue($this
    ->xpath('//select[@name="fields[_add_existing_field][field_name]"]//option[@value="' . $this->field_name . '"]'), 'Existing field was found in account settings.');
}