function ManageFieldsFunctionalTest::updateField

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

Tests editing an existing field.

1 call to ManageFieldsFunctionalTest::updateField()
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 225

Class

ManageFieldsFunctionalTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\Tests\field_ui\Functional

Code

public function updateField() {
    $field_id = 'node.' . $this->contentType . '.' . $this->fieldName;
    // Go to the field edit page.
    $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id . '/storage');
    $this->assertEscaped($this->fieldLabel);
    // Populate the field settings with new settings.
    $string = 'updated dummy test string';
    $edit = [
        'settings[test_field_storage_setting]' => $string,
    ];
    $this->drupalPostForm(NULL, $edit, t('Save field settings'));
    // Go to the field edit page.
    $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
    $edit = [
        'settings[test_field_setting]' => $string,
    ];
    $this->assertText(t('Default value'), 'Default value heading is shown');
    $this->drupalPostForm(NULL, $edit, t('Save settings'));
    // Assert the field settings are correct.
    $this->assertFieldSettings($this->contentType, $this->fieldName, $string);
    // Assert redirection back to the "manage fields" page.
    $this->assertUrl('admin/structure/types/manage/' . $this->contentType . '/fields');
}

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