function ManageFieldsFunctionalTest::testHelpDescriptions

Same name in other branches
  1. 9 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testHelpDescriptions()
  2. 10 core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testHelpDescriptions()
  3. 11.x core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsFunctionalTest::testHelpDescriptions()

Tests that help descriptions render valid HTML.

File

core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php, line 759

Class

ManageFieldsFunctionalTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\Tests\field_ui\Functional

Code

public function testHelpDescriptions() {
    // Create an image field
    FieldStorageConfig::create([
        'field_name' => 'field_image',
        'entity_type' => 'node',
        'type' => 'image',
    ])->save();
    FieldConfig::create([
        'field_name' => 'field_image',
        'entity_type' => 'node',
        'label' => 'Image',
        'bundle' => 'article',
    ])->save();
    \Drupal::service('entity_display.repository')->getFormDisplay('node', 'article')
        ->setComponent('field_image')
        ->save();
    $edit = [
        'description' => '<strong>Test with an upload field.',
    ];
    $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image', $edit, t('Save settings'));
    // Check that hook_field_widget_form_alter() does believe this is the
    // default value form.
    $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_tags');
    $this->assertText('From hook_field_widget_form_alter(): Default form is true.', 'Default value form in hook_field_widget_form_alter().');
    $edit = [
        'description' => '<em>Test with a non upload field.',
    ];
    $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags', $edit, t('Save settings'));
    $this->drupalGet('node/add/article');
    $this->assertRaw('<strong>Test with an upload field.</strong>');
    $this->assertRaw('<em>Test with a non upload field.</em>');
}

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