You are here

function ManageFieldsTest::testDuplicateFieldName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Tests/ManageFieldsTest.php \Drupal\field_ui\Tests\ManageFieldsTest::testDuplicateFieldName()

Tests that a duplicate field name is caught by validation.

File

core/modules/field_ui/src/Tests/ManageFieldsTest.php, line 596
Contains \Drupal\field_ui\Tests\ManageFieldsTest.

Class

ManageFieldsTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\field_ui\Tests

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(
    'field_name' => 'tags',
    'label' => $this
      ->randomMachineName(),
    'new_storage_type' => 'entity_reference',
  );
  $url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field';
  $this
    ->drupalPostForm($url, $edit, t('Save and continue'));
  $this
    ->assertText(t('The machine-readable name is already in use. It must be unique.'));
  $this
    ->assertUrl($url, array(), 'Stayed on the same page.');
}