You are here

protected function EntityQueryRelationshipTest::setupDerField in Dynamic Entity Reference 8.2

Helper method to setup the reference field to be tested.

2 calls to EntityQueryRelationshipTest::setupDerField()
EntityQueryRelationshipTest::testEntityQuery in tests/src/Kernel/EntityQueryRelationshipTest.php
Tests entity query for DER for entities with integer IDs.
EntityQueryRelationshipTest::testEntityQueryString in tests/src/Kernel/EntityQueryRelationshipTest.php
Tests entity query for DER for entities with string IDs.

File

tests/src/Kernel/EntityQueryRelationshipTest.php, line 184

Class

EntityQueryRelationshipTest
Tests dynamic entity reference relationship data.

Namespace

Drupal\Tests\dynamic_entity_reference\Kernel

Code

protected function setupDerField() {

  // Create a field.
  FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'type' => 'dynamic_entity_reference',
    'entity_type' => $this->entityType,
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    'settings' => [
      'exclude_entity_types' => FALSE,
      'entity_type_ids' => $this->referencedEntityTypes,
    ],
  ])
    ->save();
  FieldConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityType,
    'bundle' => $this->bundle,
    'label' => 'Field test',
    'settings' => [],
  ])
    ->save();
}