function ManageFieldsTest::addExistingField

Tests adding an existing field in another content type.

1 call to ManageFieldsTest::addExistingField()
ManageFieldsTest::testCRUDFields in drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
Runs the field CRUD tests.

File

drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php, line 161
Contains \Drupal\field_ui\Tests\ManageFieldsTest.

Class

ManageFieldsTest
Tests the functionality of the 'Manage fields' screen.

Namespace

Drupal\field_ui\Tests

Code

function addExistingField() {

  // Check "Re-use existing field" appears.
  $this
    ->drupalGet('admin/structure/types/manage/page/fields');
  $this
    ->assertRaw(t('Re-use existing field'), '"Re-use existing field" was found.');

  // Check that the list of options respects entity type restrictions on
  // fields. The 'comment' field is restricted to the 'comment' entity type
  // and should not appear in the list.
  $this
    ->assertFalse($this
    ->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value="comment"]'), 'The list of options respects entity type restrictions.');

  // Add a new field based on an existing field.
  $edit = array(
    'fields[_add_existing_field][label]' => $this->field_label . '_2',
    'fields[_add_existing_field][field_name]' => $this->field_name,
  );
  $this
    ->fieldUIAddExistingField("admin/structure/types/manage/page", $edit);
}