You are here

protected function StringFormatterTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/String/StringFormatterTest.php \Drupal\Tests\field\Kernel\String\StringFormatterTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/field/tests/src/Kernel/String/StringFormatterTest.php, line 64

Class

StringFormatterTest
Tests the creation of text fields.

Namespace

Drupal\Tests\field\Kernel\String

Code

protected function setUp() {
  parent::setUp();

  // Configure the theme system.
  $this
    ->installConfig([
    'system',
    'field',
  ]);
  \Drupal::service('router.builder')
    ->rebuild();
  $this
    ->installEntitySchema('entity_test_rev');
  $this->entityType = 'entity_test_rev';
  $this->bundle = $this->entityType;
  $this->fieldName = mb_strtolower($this
    ->randomMachineName());
  $field_storage = FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityType,
    'type' => 'string',
  ]);
  $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();
  $this->entityTypeManager = \Drupal::entityTypeManager();
}