function KernelTestBase::installEntitySchema
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installEntitySchema()
- 10 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installEntitySchema()
- 8.9.x core/modules/simpletest/src/KernelTestBase.php \Drupal\simpletest\KernelTestBase::installEntitySchema()
- 8.9.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installEntitySchema()
Installs the storage schema for a specific entity type.
Parameters
string $entity_type_id: The ID of the entity type.
95 calls to KernelTestBase::installEntitySchema()
- AccessTest::setUp in core/
modules/ file/ tests/ src/ Kernel/ AccessTest.php - BooleanFormatterTest::setUp in core/
modules/ field/ tests/ src/ Kernel/ Boolean/ BooleanFormatterTest.php - ConfigFieldDefinitionTest::setUp in core/
modules/ field/ tests/ src/ Kernel/ ConfigFieldDefinitionTest.php - Set the default field storage backend for fields created during tests.
- ConfigurableLanguageManagerTest::setUp in core/
modules/ language/ tests/ src/ Kernel/ ConfigurableLanguageManagerTest.php - ContentEntityTest::setUp in core/
modules/ migrate_drupal/ tests/ src/ Kernel/ Plugin/ migrate/ source/ ContentEntityTest.php
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 771
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
protected function installEntitySchema($entity_type_id) {
$entity_type_manager = \Drupal::entityTypeManager();
$entity_type = $entity_type_manager->getDefinition($entity_type_id);
\Drupal::service('entity_type.listener')->onEntityTypeCreate($entity_type);
// For test runs, the most common storage backend is a SQL database. For
// this case, ensure the tables got created.
$storage = $entity_type_manager->getStorage($entity_type_id);
if ($storage instanceof SqlEntityStorageInterface) {
$tables = $storage->getTableMapping()
->getTableNames();
$db_schema = $this->container
->get('database')
->schema();
foreach ($tables as $table) {
$this->assertTrue($db_schema->tableExists($table), "The entity type table '{$table}' for the entity type '{$entity_type_id}' should exist.");
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.