function RawStringFormatterTest::setUp

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php \Drupal\Tests\field\Kernel\String\RawStringFormatterTest::setUp()
  2. 8.9.x core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php \Drupal\Tests\field\Kernel\String\RawStringFormatterTest::setUp()
  3. 10 core/modules/field/tests/src/Kernel/KernelString/RawStringFormatterTest.php \Drupal\Tests\field\Kernel\KernelString\RawStringFormatterTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/field/tests/src/Kernel/KernelString/RawStringFormatterTest.php, line 56

Class

RawStringFormatterTest
Tests the raw string formatter.

Namespace

Drupal\Tests\field\Kernel\KernelString

Code

protected function setUp() : void {
    parent::setUp();
    // Configure the theme system.
    $this->installConfig([
        'system',
        'field',
    ]);
    $this->installEntitySchema('entity_test');
    $this->entityType = 'entity_test';
    $this->bundle = $this->entityType;
    $this->fieldName = $this->randomMachineName();
    $field_storage = FieldStorageConfig::create([
        'field_name' => $this->fieldName,
        'entity_type' => $this->entityType,
        'type' => 'string_long',
    ]);
    $field_storage->save();
    $instance = FieldConfig::create([
        'field_storage' => $field_storage,
        'bundle' => $this->bundle,
        'label' => $this->randomMachineName(),
    ]);
    $instance->save();
    $this->display = \Drupal::service('entity_display.repository')->getViewDisplay($this->entityType, $this->bundle)
        ->setComponent($this->fieldName, [
        'type' => 'string',
        'settings' => [],
    ]);
    $this->display
        ->save();
}

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