You are here

public function ManageFieldsFunctionalTest::addExistingField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::addExistingField()
  2. 9 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.

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');
}