function ManageFieldsFunctionalTest::updateField

Same name in other branches
  1. 8.9.x 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 220

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->assertSession()
        ->assertEscaped($this->fieldLabel);
    // Populate the field settings with new settings.
    $string = 'updated dummy test string';
    $edit = [
        'settings[test_field_storage_setting]' => $string,
    ];
    $this->submitForm($edit, '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->assertSession()
        ->pageTextContains('Default value');
    $this->submitForm($edit, 'Save settings');
    // Assert the field settings are correct.
    $this->assertFieldSettings($this->contentType, $this->fieldName, $string);
    // Assert redirection back to the "manage fields" page.
    $this->assertSession()
        ->addressEquals('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.