public function ModuleTestBase::assertModuleTablesExist in Drupal 8
Same name in this branch
- 8 core/modules/system/src/Tests/Module/ModuleTestBase.php \Drupal\system\Tests\Module\ModuleTestBase::assertModuleTablesExist()
- 8 core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesExist()
Assert that all tables defined in a module's hook_schema() exist.
Parameters
$module: The name of the module.
File
- core/
modules/ system/ src/ Tests/ Module/ ModuleTestBase.php, line 65
Class
- ModuleTestBase
- Helper class for module test cases.
Namespace
Drupal\system\Tests\ModuleCode
public function assertModuleTablesExist($module) {
$tables = array_keys(drupal_get_module_schema($module));
$tables_exist = TRUE;
$schema = Database::getConnection()
->schema();
foreach ($tables as $table) {
if (!$schema
->tableExists($table)) {
$tables_exist = FALSE;
}
}
return $this
->assertTrue($tables_exist, new FormattableMarkup('All database tables defined by the @module module exist.', [
'@module' => $module,
]));
}