You are here

private function SoftLengthLimitJavascriptTest::setupContentType in Soft Length Limit 8

Sets up the entity_test entity type with a field using soft_length_limit.

Parameters

bool $style_select: Whether to use style_select option of soft_length_limit.

Throws

\Drupal\Core\Entity\EntityStorageException

2 calls to SoftLengthLimitJavascriptTest::setupContentType()
SoftLengthLimitJavascriptTest::testSoftLengthLimitWithoutStyleSelect in tests/src/FunctionalJavascript/SoftLengthLimitJavascriptTest.php
Tests that the soft length limit widget works.
SoftLengthLimitJavascriptTest::testSoftLengthLimitWithStyleSelect in tests/src/FunctionalJavascript/SoftLengthLimitJavascriptTest.php
Tests that the soft length limit widget works.

File

tests/src/FunctionalJavascript/SoftLengthLimitJavascriptTest.php, line 104

Class

SoftLengthLimitJavascriptTest
Tests soft length limit JavaScript behavior for text fields.

Namespace

Drupal\Tests\soft_length_limit\FunctionalJavascript

Code

private function setupContentType($style_select = TRUE) : void {
  FieldStorageConfig::create([
    'type' => 'text_long',
    'entity_type' => 'entity_test',
    'field_name' => 'foo',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
    'field_name' => 'foo',
    'label' => 'Foo',
    'description' => 'Description of a text field',
  ])
    ->save();
  $widget = [
    'type' => 'text_textarea',
    'third_party_settings' => [
      'soft_length_limit' => [
        'max_limit' => 20,
        'minimum_limit' => 10,
        'style_select' => $style_select,
      ],
    ],
  ];
  EntityFormDisplay::load('entity_test.entity_test.default')
    ->setComponent('foo', $widget)
    ->save();
}