You are here

protected function DynamicEntityReferenceRelationshipTest::setUp in Dynamic Entity Reference 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/Views/DynamicEntityReferenceRelationshipTest.php \Drupal\Tests\dynamic_entity_reference\Kernel\Views\DynamicEntityReferenceRelationshipTest::setUp()

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides ViewsKernelTestBase::setUp

File

tests/src/Kernel/Views/DynamicEntityReferenceRelationshipTest.php, line 57

Class

DynamicEntityReferenceRelationshipTest
Tests dynamic entity reference relationship data.

Namespace

Drupal\Tests\dynamic_entity_reference\Kernel\Views

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp($import_test_views);
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('entity_test');
  $this
    ->installEntitySchema('entity_test_mul');
  $field_storage = FieldStorageConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_test',
    'type' => 'dynamic_entity_reference',
    'settings' => [
      'exclude_entity_types' => FALSE,
      'entity_type_ids' => [
        'entity_test',
        'entity_test_mul',
      ],
    ],
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_test',
    'bundle' => 'entity_test',
    'settings' => [],
  ]);
  $field
    ->save();
  $field_storage = FieldStorageConfig::create([
    'entity_type' => 'entity_test_mul',
    'field_name' => 'field_test_mul',
    'type' => 'dynamic_entity_reference',
    'settings' => [
      'exclude_entity_types' => FALSE,
      'entity_type_ids' => [
        'entity_test',
        'entity_test_mul',
      ],
    ],
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'entity_type' => 'entity_test_mul',
    'field_name' => 'field_test_mul',
    'bundle' => 'entity_test_mul',
    'settings' => [],
  ]);
  $field
    ->save();
  ViewTestData::createTestViews(get_class($this), [
    'dynamic_entity_reference_test_views',
  ]);
}