function ManageFieldsTest::testReuseExistingField

Same name in other branches
  1. 10 core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageFieldsTest::testReuseExistingField()

Tests re-using an existing field and the visibility of the re-use button.

File

core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php, line 89

Class

ManageFieldsTest
Tests the Field UI "Manage Fields" screens.

Namespace

Drupal\Tests\field_ui\FunctionalJavascript

Code

public function testReuseExistingField() : void {
    $path = 'admin/structure/types/manage/article';
    $path2 = 'admin/structure/types/manage/page';
    $this->drupalGet($path2 . '/fields');
    // The button should not be visible without any re-usable fields.
    $this->assertSession()
        ->linkNotExists('Re-use an existing field');
    $field_label = 'Test field';
    // Create a field, and a node with some data for the field.
    $this->fieldUIAddNewFieldJS($path, 'test', $field_label);
    // Add an existing field.
    $this->fieldUIAddExistingFieldJS($path2, 'field_test', $field_label);
    // Confirm the button is no longer visible after re-using the field.
    $this->assertSession()
        ->linkNotExists('Re-use an existing field');
}

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