function EntityFormDisplayValidationTest::testMultilineTextFieldWidgetPlaceholder

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityFormDisplayValidationTest.php \Drupal\KernelTests\Core\Entity\EntityFormDisplayValidationTest::testMultilineTextFieldWidgetPlaceholder()

Tests validation of entity form display component's widget settings.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityFormDisplayValidationTest.php, line 63

Class

EntityFormDisplayValidationTest
Tests validation of entity_form_display entities.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testMultilineTextFieldWidgetPlaceholder() : void {
    // First, create a field for which widget settings exist.
    $text_field_storage_config = FieldStorageConfig::create([
        'type' => 'text_with_summary',
        'field_name' => 'novel',
        'entity_type' => 'user',
    ]);
    $text_field_storage_config->save();
    $text_field_config = FieldConfig::create([
        'field_storage' => $text_field_storage_config,
        'bundle' => 'user',
        'dependencies' => [
            'config' => [
                $text_field_storage_config->getConfigDependencyName(),
            ],
        ],
    ]);
    $text_field_config->save();
    // Then, configure a form display widget for this field.
    assert($this->entity instanceof EntityFormDisplayInterface);
    $this->entity
        ->setComponent('novel', [
        'type' => 'text_textarea_with_summary',
        'region' => 'content',
        'settings' => [
            'rows' => 9,
            'summary_rows' => 3,
            'placeholder' => "Multi\nLine",
            'show_summary' => FALSE,
        ],
        'third_party_settings' => [],
    ]);
    $this->assertValidationErrors([]);
}

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