You are here

protected function EntityReferenceTest::setUpChildFields in Reference Table Formatter 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/EntityReferenceTest.php \Drupal\Tests\reference_table_formatter\Kernel\EntityReferenceTest::setUpChildFields()

Sets up child fields.

Parameters

string $entity_type: The entity type of referenced child entities.

string $bundle: The bundle for referenced child entities.

4 calls to EntityReferenceTest::setUpChildFields()
EntityReferenceTest::testDefaultSelectionTargetBundles in tests/src/Kernel/EntityReferenceTest.php
Tests formatting with various default selection plugin handler settings.
EntityReferenceTest::testEntityReferenceRevisions in tests/src/Kernel/EntityReferenceTest.php
Tests compatibility with entity reference revisions field type.
EntityReferenceTest::testGenericEntityFormatting in tests/src/Kernel/EntityReferenceTest.php
Tests with generic entity referencing.
EntityReferenceTest::testNoLabel in tests/src/Kernel/EntityReferenceTest.php
Tests formatting for referenced entities that have no label.

File

tests/src/Kernel/EntityReferenceTest.php, line 363

Class

EntityReferenceTest
Tests the entity reference table formatter.

Namespace

Drupal\Tests\reference_table_formatter\Kernel

Code

protected function setUpChildFields($entity_type, $bundle) {

  // Setup a generic field to be used on referenced entities.
  $field_storage = FieldStorageConfig::create([
    'entity_type' => $entity_type,
    'field_name' => 'field_string',
    'type' => 'string',
  ]);
  $field_storage
    ->save();
  FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => $bundle,
    'label' => 'String Field',
  ])
    ->save();
  $this->container
    ->get('entity_display.repository')
    ->getViewDisplay($entity_type, $bundle)
    ->setComponent('field_string')
    ->save();
}