protected function ManageFieldsFunctionalTest::addPersistentFieldStorage 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::addPersistentFieldStorage()
- 10 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::addPersistentFieldStorage()
Tests that persistent field storage appears in the field UI.
1 call to ManageFieldsFunctionalTest::addPersistentFieldStorage()
- ManageFieldsFunctionalTest::testCRUDFields in core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php - Runs the field CRUD tests.
File
- core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php, line 411
Class
- ManageFieldsFunctionalTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
protected function addPersistentFieldStorage() {
$field_storage = FieldStorageConfig::loadByName('node', $this->fieldName);
// Persist the field storage even if there are no fields.
$field_storage
->set('persist_with_no_fields', TRUE)
->save();
// Delete all instances of the field.
foreach ($field_storage
->getBundles() as $node_type) {
// Delete all the body field instances.
$this
->drupalGet('admin/structure/types/manage/' . $node_type . '/fields/node.' . $node_type . '.' . $this->fieldName);
$this
->clickLink(t('Delete'));
$this
->drupalPostForm(NULL, [], t('Delete'));
}
// Check "Re-use existing field" appears.
$this
->drupalGet('admin/structure/types/manage/page/fields/add-field');
$this
->assertRaw(t('Re-use an existing field'), '"Re-use existing field" was found.');
// Ensure that we test with a label that contains HTML.
$label = $this
->randomString(4) . '<br/>' . $this
->randomString(4);
// Add a new field for the orphaned storage.
$this
->fieldUIAddExistingField("admin/structure/types/manage/page", $this->fieldName, $label);
}