You are here

protected function StringFormatterTest::setUp in Zircon Profile 8

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

Performs setup tasks before each individual test method is run.

Overrides KernelTestBase::setUp

File

core/modules/field/src/Tests/String/StringFormatterTest.php, line 56
Contains \Drupal\field\Tests\String\StringFormatterTest.

Class

StringFormatterTest
Tests the creation of text fields.

Namespace

Drupal\field\Tests\String

Code

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

  // Configure the theme system.
  $this
    ->installConfig(array(
    'system',
    'field',
  ));
  $this
    ->installSchema('system', 'router');
  \Drupal::service('router.builder')
    ->rebuild();
  $this
    ->installEntitySchema('entity_test_rev');
  $this->entityType = 'entity_test_rev';
  $this->bundle = $this->entityType;
  $this->fieldName = Unicode::strtolower($this
    ->randomMachineName());
  $field_storage = FieldStorageConfig::create(array(
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityType,
    'type' => 'string',
  ));
  $field_storage
    ->save();
  $instance = FieldConfig::create(array(
    'field_storage' => $field_storage,
    'bundle' => $this->bundle,
    'label' => $this
      ->randomMachineName(),
  ));
  $instance
    ->save();
  $this->display = entity_get_display($this->entityType, $this->bundle, 'default')
    ->setComponent($this->fieldName, array(
    'type' => 'string',
    'settings' => array(),
  ));
  $this->display
    ->save();
}