You are here

protected function LinkStubReplicationTest::createLinkField in Replication 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/LinkStubReplicationTest.php \Drupal\Tests\replication\Kernel\LinkStubReplicationTest::createLinkField()

Create link field for entity type.

Parameters

string $entity_type: Entity type.

string $bundle: Entity type bundle.

$field_name: Name of the link field to create.

1 call to LinkStubReplicationTest::createLinkField()
LinkStubReplicationTest::setUp in tests/src/Kernel/LinkStubReplicationTest.php

File

tests/src/Kernel/LinkStubReplicationTest.php, line 210

Class

LinkStubReplicationTest
Tests link stub replication.

Namespace

Drupal\Tests\replication\Kernel

Code

protected function createLinkField($entity_type, $bundle, $field_name) {
  FieldStorageConfig::create([
    'field_name' => $field_name,
    'entity_type' => $entity_type,
    'type' => 'link',
    'cardinality' => 2,
    'translatable' => FALSE,
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => $entity_type,
    'field_name' => $field_name,
    'bundle' => $bundle,
    'label' => 'Test link-field',
    'widget' => [
      'type' => 'link',
      'weight' => 0,
    ],
  ])
    ->save();
}