function ManageFieldsFunctionalTest::addExistingField

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

Tests adding an existing field in another content type.

1 call to ManageFieldsFunctionalTest::addExistingField()
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 251

Class

ManageFieldsFunctionalTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\Tests\field_ui\Functional

Code

public function addExistingField() {
    // Check "Re-use existing field" appears.
    $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
    $this->assertSession()
        ->pageTextContains('Re-use an existing field');
    // Check that fields of other entity types (here, the 'comment_body' field)
    // do not show up in the "Re-use existing field" list.
    $this->assertSession()
        ->optionNotExists('edit-existing-storage-name', 'comment');
    // Validate the FALSE assertion above by also testing a valid one.
    $this->assertSession()
        ->optionExists('edit-existing-storage-name', $this->fieldName);
    // Add a new field based on an existing field.
    $this->fieldUIAddExistingField("admin/structure/types/manage/page", $this->fieldName, $this->fieldLabel . '_2');
}

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