function ModuleTestBase::assertModuleTablesDoNotExist

Same name in this branch
  1. 8.9.x core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesDoNotExist()
Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesDoNotExist()
  2. 10 core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesDoNotExist()
  3. 11.x core/modules/system/tests/src/Functional/Module/ModuleTestBase.php \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesDoNotExist()

Assert that none of the 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 83

Class

ModuleTestBase
Helper class for module test cases.

Namespace

Drupal\system\Tests\Module

Code

public function assertModuleTablesDoNotExist($module) {
    $tables = array_keys(drupal_get_module_schema($module));
    $tables_exist = FALSE;
    $schema = Database::getConnection()->schema();
    foreach ($tables as $table) {
        if ($schema->tableExists($table)) {
            $tables_exist = TRUE;
        }
    }
    return $this->assertFalse($tables_exist, new FormattableMarkup('None of the database tables defined by the @module module exist.', [
        '@module' => $module,
    ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.