protected function DynamicEntityReferenceFieldDependencyTest::setUp in Dynamic Entity Reference 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DynamicEntityReferenceFieldDependencyTest.php \Drupal\Tests\dynamic_entity_reference\Kernel\DynamicEntityReferenceFieldDependencyTest::setUp()
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ DynamicEntityReferenceFieldDependencyTest.php, line 44
Class
- DynamicEntityReferenceFieldDependencyTest
- Tests for dynamic entity reference field dependencies.
Namespace
Drupal\Tests\dynamic_entity_reference\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('entity_test');
$this->fieldStorage = FieldStorageConfig::create([
'type' => 'dynamic_entity_reference',
'field_name' => strtolower($this
->randomMachineName()),
'entity_type' => 'entity_test',
]);
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */
$entityTypeManager = $this->container
->get('entity_type.manager');
// Gather the provider ID's of all content entity types.
foreach ($entityTypeManager
->getDefinitions() as $entity_id => $entity_type) {
if ($entity_type instanceof ContentEntityTypeInterface) {
$provider = $entity_type
->getProvider();
if (!in_array($provider, $this->entityTypeProviders) && $provider !== 'core') {
$this->entityTypeProviders[] = $provider;
}
}
}
}