You are here

public function TextRequiredSummaryUpdateTest::testFieldAndWidgetUpdate in Drupal 8

Tests that widgets and fields are updated for required summary flag.

See also

text_post_update_add_required_summary_flag()

File

core/modules/text/tests/src/Functional/TextRequiredSummaryUpdateTest.php, line 36

Class

TextRequiredSummaryUpdateTest
Tests updates for adding required summary flags to widgets and fields.

Namespace

Drupal\Tests\text\Functional

Code

public function testFieldAndWidgetUpdate() {

  // No show summary flag exists pre-update.
  $entity_form_display = EntityFormDisplay::load('node.article.default');
  $options = $entity_form_display
    ->getComponent('body');
  $this
    ->assertFalse(array_key_exists('show_summary', $options['settings']));
  $field = FieldConfig::load('node.article.body');
  $settings = $field
    ->getSettings();
  $this
    ->assertFalse(array_key_exists('required_summary', $settings));
  $this
    ->runUpdates();

  // The show summary setting has been populated on the widget.
  $entity_form_display = EntityFormDisplay::load('node.article.default');
  $options = $entity_form_display
    ->getComponent('body');
  $this
    ->assertIdentical(FALSE, $options['settings']['show_summary']);

  // And the so has the required sumamry setting on the field.
  $field = FieldConfig::load('node.article.body');
  $settings = $field
    ->getSettings();
  $this
    ->assertIdentical(FALSE, $settings['required_summary']);
}