You are here

protected function LinkItemTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/link/tests/src/Kernel/LinkItemTest.php \Drupal\Tests\link\Kernel\LinkItemTest::setUp()
  2. 9 core/modules/link/tests/src/Kernel/LinkItemTest.php \Drupal\Tests\link\Kernel\LinkItemTest::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() : void {
  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();
}