You are here

function ManageFieldsTest::testHelpDescriptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Tests/ManageFieldsTest.php \Drupal\field_ui\Tests\ManageFieldsTest::testHelpDescriptions()

Tests that help descriptions render valid HTML.

File

core/modules/field_ui/src/Tests/ManageFieldsTest.php, line 646
Contains \Drupal\field_ui\Tests\ManageFieldsTest.

Class

ManageFieldsTest
Tests the Field UI "Manage fields" screen.

Namespace

Drupal\field_ui\Tests

Code

function testHelpDescriptions() {

  // Create an image field
  FieldStorageConfig::create(array(
    'field_name' => 'field_image',
    'entity_type' => 'node',
    'type' => 'image',
  ))
    ->save();
  FieldConfig::create(array(
    'field_name' => 'field_image',
    'entity_type' => 'node',
    'label' => 'Image',
    'bundle' => 'article',
  ))
    ->save();
  entity_get_form_display('node', 'article', 'default')
    ->setComponent('field_image')
    ->save();
  $edit = array(
    '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 = array(
    '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>');
}