function ManageFieldsFunctionalTest::testDeleteTaxonomyField

Same name in other branches
  1. 8.9.x core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testDeleteTaxonomyField()

Tests that deletion removes field storages and fields as expected for a term.

File

core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php, line 757

Class

ManageFieldsFunctionalTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\Tests\field_ui\Functional

Code

public function testDeleteTaxonomyField() {
    // Create a new field.
    $bundle_path = 'admin/structure/taxonomy/manage/tags/overview';
    $this->fieldUIAddNewField($bundle_path, $this->fieldNameInput, $this->fieldLabel);
    // Delete the field.
    $this->fieldUIDeleteField($bundle_path, "taxonomy_term.tags.{$this->fieldName}", $this->fieldLabel, 'Tags');
    // Check that the field was deleted.
    $this->assertNull(FieldConfig::loadByName('taxonomy_term', 'tags', $this->fieldName), 'Field was deleted.');
    // Check that the field storage was deleted too.
    $this->assertNull(FieldStorageConfig::loadByName('taxonomy_term', $this->fieldName), 'Field storage was deleted.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.