1 field_ui.test FieldUIManageFieldsTestCase::testDuplicateFieldName()

Tests that a duplicate field name is caught by validation.

File

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

Class

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

Code

function testDuplicateFieldName() {
  // field_tags already exists, so we're expecting an error when trying to
  // create a new field with the same name.
  $edit = array(
    'fields[_add_new_field][field_name]' => 'tags',
    'fields[_add_new_field][label]' => $this->randomName(),
    'fields[_add_new_field][type]' => 'taxonomy_term_reference',
    'fields[_add_new_field][widget_type]' => 'options_select',
  );
  $url = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields';
  $this->backdropPost($url, $edit, t('Save'));

  $this->assertText(t('The machine-readable name is already in use. It must be unique.'));
  $this->assertUrl($url, array(), 'Stayed on the same page.');
}