public function DynamicEntityReferenceConfigEntityBaseFieldTest::testBaseField in Dynamic Entity Reference 8.2
Config entity only base DER field.
File
- tests/
src/ Kernel/ DynamicEntityReferenceConfigEntityBaseFieldTest.php, line 98
Class
- DynamicEntityReferenceConfigEntityBaseFieldTest
- Base field tests for referencing config entities.
Namespace
Drupal\Tests\dynamic_entity_reference\KernelCode
public function testBaseField() {
// @see dynamic_entity_reference_entity_test_entity_base_field_info()
$this
->enableModules([
'dynamic_entity_reference_entity_test',
]);
// Reference a config entity.
$entity = $this->container
->get('entity_type.manager')
->getStorage($this->entityType)
->create([
'type' => $this->bundle,
]);
$entity->{$this->fieldName}->target_type = $this->configTestReference
->getEntityTypeId();
$entity->{$this->fieldName}->target_id = $this->configTestReference
->id();
$violations = $entity->{$this->fieldName}
->validate();
$this
->assertEmpty($violations
->count(), 'Validation passes.');
}