function ManageFieldsFunctionalTest::testDuplicateFieldName
Same name in other branches
- 8.9.x core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testDuplicateFieldName()
Tests that a duplicate field name is caught by validation.
File
-
core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php, line 723
Class
- ManageFieldsFunctionalTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
public function testDuplicateFieldName() {
// field_tags already exists, so we're expecting an error when trying to
// create a new field with the same name.
$edit = [
'field_name' => 'tags',
'label' => $this->randomMachineName(),
'new_storage_type' => 'entity_reference',
];
$url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field';
$this->drupalGet($url);
$this->submitForm($edit, 'Save and continue');
$this->assertSession()
->pageTextContains('The machine-readable name is already in use. It must be unique.');
$this->assertSession()
->addressEquals($url);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.