You are here

protected function LinkItemTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/link/tests/src/Kernel/LinkItemTest.php \Drupal\Tests\link\Kernel\LinkItemTest::setUp()

Set the default field storage backend for fields created during tests.

Overrides FieldKernelTestBase::setUp

File

core/modules/link/tests/src/Kernel/LinkItemTest.php, line 29

Class

LinkItemTest
Tests the new entity API for the link field type.

Namespace

Drupal\Tests\link\Kernel

Code

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

  // Create a generic, external, and internal link fields for validation.
  FieldStorageConfig::create([
    'field_name' => 'field_test',
    'entity_type' => 'entity_test',
    'type' => 'link',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_test',
    'bundle' => 'entity_test',
    'settings' => [
      'link_type' => LinkItemInterface::LINK_GENERIC,
    ],
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_test_external',
    'entity_type' => 'entity_test',
    'type' => 'link',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_test_external',
    'bundle' => 'entity_test',
    'settings' => [
      'link_type' => LinkItemInterface::LINK_EXTERNAL,
    ],
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_test_internal',
    'entity_type' => 'entity_test',
    'type' => 'link',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_test_internal',
    'bundle' => 'entity_test',
    'settings' => [
      'link_type' => LinkItemInterface::LINK_INTERNAL,
    ],
  ])
    ->save();
}