You are here

protected function FieldOutputTest::setUp in Fences 8.2

Overrides KernelTestBase::setUp

File

tests/src/Kernel/FieldOutputTest.php, line 183

Class

FieldOutputTest
Test the field output under different configurations.

Namespace

Drupal\Tests\fences\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema($this->entityTypeId);
  $this
    ->installEntitySchema('filter_format');

  // Setup a field and an entity display.
  EntityViewDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    'mode' => 'default',
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityTypeId,
    'type' => 'text',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => $this->entityTypeId,
    'field_name' => $this->fieldName,
    'bundle' => $this->entityTypeId,
  ])
    ->save();
  $this->entityViewDisplay = EntityViewDisplay::load('entity_test.entity_test.default');

  // Create a test entity with a test value.
  $this->entity = EntityTest::create();
  $this->entity->{$this->fieldName}->value = 'lorem ipsum';
  $this->entity
    ->save();

  // Set the default filter format.
  FilterFormat::create([
    'format' => 'test_format',
    'name' => $this
      ->randomMachineName(),
  ])
    ->save();
  $this->container
    ->get('config.factory')
    ->getEditable('filter.settings')
    ->set('fallback_format', 'test_format')
    ->save();
}