You are here

protected function KernelTestBase::installEntitySchema in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installEntitySchema()
  2. 9 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.

203 calls to KernelTestBase::installEntitySchema()
AccessPermissionTest::setUp in core/modules/user/tests/src/Kernel/Views/AccessPermissionTest.php
ActionTest::setUp in core/modules/system/tests/src/Kernel/Action/ActionTest.php
ArgumentDefaultTest::testPluginArgumentDefaultCurrentUser in core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php
Tests the current user with argument default.
ArgumentNodeRevisionIdTest::setUp in core/modules/node/tests/src/Kernel/Views/ArgumentNodeRevisionIdTest.php
ArgumentUidRevisionTest::setUp in core/modules/node/tests/src/Kernel/Views/ArgumentUidRevisionTest.php

... See full list

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 748

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

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.");
    }
  }
}