function ManageFieldsTest::testDisallowedFieldNames in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field_ui/src/Tests/ManageFieldsTest.php \Drupal\field_ui\Tests\ManageFieldsTest::testDisallowedFieldNames()
Tests that Field UI respects disallowed field names.
File
- core/
modules/ field_ui/ src/ Tests/ ManageFieldsTest.php, line 482 - Contains \Drupal\field_ui\Tests\ManageFieldsTest.
Class
- ManageFieldsTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\field_ui\TestsCode
function testDisallowedFieldNames() {
// Reset the field prefix so we can test properly.
$this
->config('field_ui.settings')
->set('field_prefix', '')
->save();
$label = 'Disallowed field';
$edit = array(
'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.'));
}