public function ManageFieldsFunctionalTest::testDisallowedFieldNames in Drupal 8
Same name and namespace in other branches
- 9 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testDisallowedFieldNames()
Tests that Field UI respects disallowed field names.
File
- core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php, line 597
Class
- ManageFieldsFunctionalTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
public function testDisallowedFieldNames() {
// Reset the field prefix so we can test properly.
$this
->config('field_ui.settings')
->set('field_prefix', '')
->save();
$label = 'Disallowed field';
$edit = [
'label' => $label,
'new_storage_type' => 'test_field',
];
// Try with an entity key.
$edit['field_name'] = 'title';
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
$this
->drupalPostForm("{$bundle_path}/fields/add-field", $edit, t('Save and continue'));
$this
->assertText(t('The machine-readable name is already in use. It must be unique.'));
// Try with a base field.
$edit['field_name'] = 'sticky';
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
$this
->drupalPostForm("{$bundle_path}/fields/add-field", $edit, t('Save and continue'));
$this
->assertText(t('The machine-readable name is already in use. It must be unique.'));
}