function FieldConfigValidationTest::testMultilineTextFieldDefaultValue

Same name and namespace in other branches
  1. 11.x core/modules/field/tests/src/Kernel/Entity/FieldConfigValidationTest.php \Drupal\Tests\field\Kernel\Entity\FieldConfigValidationTest::testMultilineTextFieldDefaultValue()

Tests validation of a field_config's default value.

File

core/modules/field/tests/src/Kernel/Entity/FieldConfigValidationTest.php, line 73

Class

FieldConfigValidationTest
Tests validation of field_config entities.

Namespace

Drupal\Tests\field\Kernel\Entity

Code

public function testMultilineTextFieldDefaultValue() : void {
  // First, create a field storage for which a complex default value exists.
  $this->enableModules([
    'text',
  ]);
  $text_field_storage_config = FieldStorageConfig::create([
    'type' => 'text_with_summary',
    'field_name' => 'novel',
    'entity_type' => 'user',
  ]);
  $text_field_storage_config->save();
  $this->entity = FieldConfig::create([
    'field_storage' => $text_field_storage_config,
    'bundle' => 'user',
    'default_value' => [
      0 => [
        'value' => "Multi\nLine",
        'summary' => '',
        'format' => 'basic_html',
      ],
    ],
    'dependencies' => [
      'config' => [
        $text_field_storage_config->getConfigDependencyName(),
      ],
    ],
  ]);
  $this->assertValidationErrors([]);
}

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