You are here

protected function SubtitleFormatterTest::setUp in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/Plugin/Field/FieldFormatter/SubtitleFormatterTest.php \Drupal\Tests\fb_instant_articles\Kernel\Plugin\Field\FieldFormatter\SubtitleFormatterTest::setUp()

Overrides FormatterTestBase::setUp

File

tests/src/Kernel/Plugin/Field/FieldFormatter/SubtitleFormatterTest.php, line 37

Class

SubtitleFormatterTest
Tests the SubtitleFormatterTest.

Namespace

Drupal\Tests\fb_instant_articles\Kernel\Plugin\Field\FieldFormatter

Code

protected function setUp() : void {
  parent::setUp();
  $this->textFieldName = mb_strtolower($this
    ->randomMachineName());
  $field_storage = FieldStorageConfig::create([
    'field_name' => $this->textFieldName,
    'entity_type' => $this->entityType,
    'type' => 'text_long',
  ]);
  $field_storage
    ->save();
  $instance = FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => $this->bundle,
    'label' => $this
      ->randomMachineName(),
  ]);
  $instance
    ->save();
  $this
    ->installConfig([
    'text',
    'filter',
    'filter_test',
  ]);

  // We have to save the display that's been partially setup already and then
  // reload it, b/c the display caches field definitions at initialization.
  // This way the field defined above will be allowed to be configured on the
  // display.
  $this->display
    ->save();
  $this->display = EntityViewDisplay::load($this->display
    ->id());

  // Setup entity view display with default settings.
  $this->display
    ->setComponent($this->textFieldName, [
    'type' => 'fbia_subtitle',
    'settings' => [],
  ]);
  $this->display
    ->setComponent($this->fieldName, [
    'type' => 'fbia_subtitle',
    'settings' => [],
  ]);
  $this->display
    ->save();
}