function FieldUIManageFieldsTestCase::testDuplicateFieldName

Tests that a duplicate field name is caught by validation.

File

modules/field_ui/field_ui.test, line 439

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->drupalPost($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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.