public function ManageFieldsFunctionalTest::testDuplicateFieldName in Drupal 9
Same name and namespace in other branches
- 8 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 725
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);
}