function LinkFormatterTest::setUp

Overrides EntityKernelTestBase::setUp

File

core/modules/link/tests/src/Kernel/LinkFormatterTest.php, line 58

Class

LinkFormatterTest
Tests the Field Formatter for the link field type.

Namespace

Drupal\Tests\link\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  // Use Stark theme for testing markup output.
  \Drupal::service('theme_installer')->install([
    'stark',
  ]);
  $this->config('system.theme')
    ->set('default', 'stark')
    ->save();
  $this->installEntitySchema('entity_test');
  // Grant the 'view test entity' permission.
  $this->installConfig([
    'user',
  ]);
  Role::load(RoleInterface::ANONYMOUS_ID)->grantPermission('view test entity')
    ->save();
  FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'type' => 'link',
    'entity_type' => $this->entityType,
    'cardinality' => 1,
  ])
    ->save();
  FieldConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityType,
    'bundle' => $this->bundle,
    'label' => 'Field test',
  ])
    ->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.