You are here

public function DatabaseLegacyTest::testDbRenameTable in Drupal 8

Tests deprecation of the db_rename_table() function.

@expectedDeprecation db_rename_table() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call renameTable() on it. For example, $injected_database->schema()->renameTable($table, $new_name). See https://www.drupal.org/node/2993033

File

core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php, line 347

Class

DatabaseLegacyTest
Deprecation tests cases for the database layer.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDbRenameTable() {
  $this
    ->assertTrue($this->connection
    ->schema()
    ->tableExists('test'));
  db_rename_table('test', 'test_rename');
  $this
    ->assertTrue($this->connection
    ->schema()
    ->tableExists('test_rename'));
}