function ModuleInstallerTest::testFieldStorageEntityTypeDependencies
Tests field storage definitions are installed only if entity types exist.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Extension/ ModuleInstallerTest.php, line 250
Class
- ModuleInstallerTest
- Tests the ModuleInstaller class.
Namespace
Drupal\KernelTests\Core\ExtensionCode
public function testFieldStorageEntityTypeDependencies() : void {
$profile = 'minimal';
$this->setInstallProfile($profile);
// Install a module that will make workspaces a dependency of taxonomy.
\Drupal::service('module_installer')->install([
'field_storage_entity_type_dependency_test',
]);
// Installing taxonomy will install workspaces first. During installation of
// workspaces, the storage for 'workspace' field should not be attempted
// before the taxonomy term entity storage has been created, so there
// should not be a EntityStorageException logged.
\Drupal::service('module_installer')->install([
'taxonomy',
]);
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('workspaces'));
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('taxonomy'));
$this->assertArrayHasKey('workspace', \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('taxonomy_term'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.