You are here

protected function LinkIframeFormatterTest::setUp in Link iframe formatter 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/LinkIframeFormatterTest.php \Drupal\Tests\link_iframe_formatter\Functional\LinkIframeFormatterTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/LinkIframeFormatterTest.php, line 34

Class

LinkIframeFormatterTest
Defines a class for testing link iframe formatter.

Namespace

Drupal\Tests\link_iframe_formatter\Functional

Code

protected function setUp() : void {
  parent::setUp();
  if (!FieldStorageConfig::load('entity_test.link')) {
    $storage = FieldStorageConfig::create([
      'entity_type' => 'entity_test',
      'field_name' => 'link',
      'id' => 'entity_test.link',
      'type' => 'link',
    ]);
    $storage
      ->save();
  }
  if (!FieldConfig::load('entity_test.entity_test.link')) {
    $config = FieldConfig::create([
      'field_name' => 'link',
      'entity_type' => 'entity_test',
      'bundle' => 'entity_test',
      'id' => 'entity_test.entity_test.link',
      'label' => 'Link',
    ]);
    $config
      ->save();
  }
  $display = \Drupal::service('entity_display.repository')
    ->getViewDisplay('entity_test', 'entity_test');
  assert($display instanceof EntityViewDisplayInterface);
  $display
    ->setComponent('link', [
    'type' => 'link_iframe_formatter',
    'settings' => [
      'width' => 350,
      'height' => 270,
      'class' => 'some-class',
      'original' => TRUE,
    ],
  ]);
  $display
    ->save();
}