public function DynamicEntityReferenceConfigEntityTest::testConfigurableField in Dynamic Entity Reference 8.2
Config entity only configurable DER field.
File
- tests/src/ Kernel/ DynamicEntityReferenceConfigEntityTest.php, line 142 
Class
- DynamicEntityReferenceConfigEntityTest
- Tests for referencing configuration entities with configurable fields.
Namespace
Drupal\Tests\dynamic_entity_reference\KernelCode
public function testConfigurableField() {
  $this
    ->setUpField();
  $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
    ->assertEquals($violations
    ->count(), 0, 'Validation passes.');
}