protected function DynamicEntityReferenceFieldTest::setUp in Dynamic Entity Reference 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DynamicEntityReferenceFieldTest.php \Drupal\Tests\dynamic_entity_reference\Kernel\DynamicEntityReferenceFieldTest::setUp()
Overrides EntityKernelTestBase::setUp
File
- tests/
src/ Kernel/ DynamicEntityReferenceFieldTest.php, line 58
Class
- DynamicEntityReferenceFieldTest
- Tests for the dynamic entity reference field.
Namespace
Drupal\Tests\dynamic_entity_reference\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('entity_test_with_bundle');
// 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->referencedEntityType,
],
],
])
->save();
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $this->entityType,
'bundle' => $this->bundle,
'label' => 'Field test',
'settings' => [
$this->referencedEntityType => [
'handler' => 'default:' . $this->referencedEntityType,
'handler_settings' => [
'target_bundles' => NULL,
],
],
],
])
->save();
}