diff --git a/core/modules/filter/src/Tests/FilterTextFieldWidgetTest.php b/core/modules/filter/src/Tests/FilterTextFieldWidgetTest.php
new file mode 100644
index 0000000..d9f9394
--- /dev/null
+++ b/core/modules/filter/src/Tests/FilterTextFieldWidgetTest.php
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\filter\Tests\FilterTextFieldWidgetTest.
+ */
+
+namespace Drupal\filter\Tests;
+
+use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\Unicode;
+use Drupal\filter\Entity\FilterFormat;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Thoroughly test the administrative interface of the filter module.
+ *
+ * @group filter
+ */
+class FilterTextFieldWidgetTest extends WebTestBase {
+
+  /**
+   * The admin user.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $adminUser;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = array('filter', 'user', 'text', 'field_ui');
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    // Use seven.
+    $this->container->get('theme_handler')->install(array('seven'));
+    $this->container->get('config.factory')
+      ->get('system.theme')
+      ->set('default', 'seven')
+      ->set('admin', 'seven')
+      ->save();
+
+    // Set up the filter formats used by this test.
+    /* @var \Drupal\filter\FilterFormatInterface $basic_html_format */
+    $basic_html_format = FilterFormat::create([
+      'format' => 'basic_html',
+      'name' => 'Basic HTML',
+      'filters' => [
+        'filter_html' => [
+          'status' => 1,
+          'settings' => [
+            'allowed_html' => '<p> <br> <strong> <a> <em>',
+          ],
+        ],
+      ],
+    ]);
+    $basic_html_format->save();
+    /* @var \Drupal\filter\FilterFormatInterface $basic_html_format */
+    $full_html_format = FilterFormat::create([
+      'format' => 'full_html',
+      'name' => 'Full HTML',
+      'filters' => []
+    ]);
+    $full_html_format->save();
+    $this->adminUser = $this->drupalCreateUser([
+      'administer filters',
+      'administer user fields',
+      $basic_html_format->getPermissionName(),
+      $full_html_format->getPermissionName(),
+    ]);
+
+    $this->drupalLogin($this->adminUser);
+  }
+
+  /**
+   * Tests the text widget on the user form.
+   */
+  public function testUserTextFieldWidget() {
+    // Add field.
+    $this->drupalGet('admin/config/people/accounts/fields');
+    $this->drupalPostForm(NULL, [
+      'fields[_add_new_field][label]' => 'baloney',
+      'fields[_add_new_field][field_name]' => 'baloney',
+      'fields[_add_new_field][type]' => 'text',
+    ], t('Save'));
+    $this->drupalPostForm(NULL, [], t('Save field settings'));
+    $this->drupalPostForm(NULL, [], t('Save settings'));
+    $this->drupalGet('user/' . $this->adminUser->id() . '/edit');
+    $this->assertFieldByName('field_baloney[0][value]');
+  }
+
+}
diff --git a/core/modules/filter/src/Tests/TextFormatElementFormTest.php b/core/modules/filter/src/Tests/TextFormatElementFormTest.php
new file mode 100644
index 0000000..4e399e4
--- /dev/null
+++ b/core/modules/filter/src/Tests/TextFormatElementFormTest.php
@@ -0,0 +1,136 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\filter\Tests\TextFormatElementFormTest.
+ */
+
+namespace Drupal\filter\Tests;
+
+use Drupal\Core\Form\FormInterface;
+use Drupal\Core\Form\FormState;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\Element\PathElement;
+use Drupal\Core\Url;
+use Drupal\filter\Entity\FilterFormat;
+use Drupal\simpletest\KernelTestBase;
+use Drupal\user\Entity\Role;
+use Drupal\user\Entity\User;
+
+/**
+ * Tests PathElement validation and conversion functionality.
+ *
+ * @group Form
+ */
+class TextFormatElementFormTest extends KernelTestBase implements FormInterface {
+
+  /**
+   * User for testing.
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $testUser;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = array('system', 'user', 'filter', 'filter_test');
+
+  /**
+   * Sets up the test.
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installEntitySchema('user');
+    $this->installSchema('system', ['sequences', 'router']);
+    $this->installConfig(['filter', 'filter_test']);
+    // Filter tips link to the full-page.
+    \Drupal::service('router.builder')->rebuild();
+    /* @var \Drupal\Core\Render\ElementInfoManager $manager */
+    $manager = \Drupal::service('plugin.manager.element_info');
+    $manager->clearCachedDefinitions();
+    $manager->getDefinitions();
+    /* @var \Drupal\filter\FilterFormatInterface $filter_test_format */
+    $filter_test_format = FilterFormat::load('filter_test');
+
+    /* @var \Drupal\user\RoleInterface $role */
+    $role = Role::create([
+      'id' => 'admin',
+      'label' => 'admin',
+    ]);
+    $role->grantPermission($filter_test_format->getPermissionName());
+    $role->save();
+    $this->testUser = User::create([
+      'name' => 'foobar',
+      'mail' => 'foobar@example.com',
+    ]);
+    $this->testUser->addRole($role->id());
+    $this->testUser->save();
+    \Drupal::service('current_user')->setAccount($this->testUser);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'test_text_area_element';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    // A textformat field.
+    $form['textformat'] = [
+      '#type' => 'text_format',
+      '#required' => TRUE,
+      '#title' => 'Text',
+      '#base_type' => 'textfield',
+      '#format' => NULL,
+      '#default_value' => 'test value',
+    ];
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {}
+
+  /**
+   * Form validation handler.
+   *
+   * @param array $form
+   *   An associative array containing the structure of the form.
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
+   *   The current state of the form.
+   */
+  public function validateForm(array &$form, FormStateInterface $form_state) {}
+
+  /**
+   * Tests that values are returned.
+   */
+  public function testTextFormatElement() {
+    $form_state = new FormState();
+    $form_state->setBuildInfo(['callback_object' => $this, 'args' => []]);
+    /* @var \Drupal\Core\Form\FormBuilder $form_builder */
+    $form_builder = $this->container->get('form_builder');
+    $form = $form_builder->buildForm($this, $form_state);
+    $output = $this->render($form);
+    $this->setRawContent($output);
+    $this->assertFieldByName('textformat[value]');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getUrl() {
+    // \Drupal\simpletest\AssertContentTrait needs this for ::assertFieldByName
+    // to work.
+    return 'Internal rendering';
+  }
+
+}
