You are here

public static function SchemaInspector::getTablesSpecification in Drupal 9

Same name and namespace in other branches
  1. 10 core/tests/Drupal/TestTools/Extension/SchemaInspector.php \Drupal\TestTools\Extension\SchemaInspector::getTablesSpecification()

Returns the module's schema specification.

This function can be used to retrieve a schema specification provided by hook_schema(), so it allows you to derive your tables from existing specifications.

Parameters

\Drupal\Core\Extension\ModuleHandlerInterface $handler: The module handler to use for calling schema hook.

string $module: The module to which the table belongs.

Return value

array An array of schema definition provided by hook_schema().

See also

\hook_schema()

3 calls to SchemaInspector::getTablesSpecification()
KernelTestBase::installSchema in core/tests/Drupal/KernelTests/KernelTestBase.php
Installs database tables from a module schema definition.
ModuleTestBase::assertModuleTablesDoNotExist in core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
Assert that none of the tables defined in a module's hook_schema() exist.
ModuleTestBase::assertModuleTablesExist in core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
Assert that all tables defined in a module's hook_schema() exist.

File

core/tests/Drupal/TestTools/Extension/SchemaInspector.php, line 29

Class

SchemaInspector
Provides methods to access modules' schema.

Namespace

Drupal\TestTools\Extension

Code

public static function getTablesSpecification(ModuleHandlerInterface $handler, string $module) : array {
  if ($handler
    ->loadInclude($module, 'install')) {
    return $handler
      ->invoke($module, 'schema') ?? [];
  }
  return [];
}