Issue #2848808 by voleger, gaurav.kapoor, andypost, Vidushi Mehta, sidharthap: Replace all calls to db_find_tables, which is deprecated
parent
383f701fe8
commit
b083070276
|
@ -721,6 +721,10 @@ function db_field_exists($table, $field) {
|
|||
* @see \Drupal\Core\Database\Schema::findTables()
|
||||
*/
|
||||
function db_find_tables($table_expression) {
|
||||
@trigger_error(
|
||||
'db_find_tables() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use $injected_database->schema()->findTables($table_expression) instead. See https://www.drupal.org/node/2993033',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
return Database::getConnection()->schema()->findTables($table_expression);
|
||||
}
|
||||
|
||||
|
|
|
@ -670,7 +670,7 @@ function simpletest_clean_environment() {
|
|||
*/
|
||||
function simpletest_clean_database() {
|
||||
$schema = Database::getConnection()->schema();
|
||||
$tables = db_find_tables('test%');
|
||||
$tables = $schema->findTables('test%');
|
||||
$count = 0;
|
||||
foreach ($tables as $table) {
|
||||
// Only drop tables which begin wih 'test' followed by digits, for example,
|
||||
|
|
|
@ -42,7 +42,8 @@ abstract class ModuleTestBase extends WebTestBase {
|
|||
* specified base table. Defaults to TRUE.
|
||||
*/
|
||||
public function assertTableCount($base_table, $count = TRUE) {
|
||||
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
|
||||
$connection = Database::getConnection();
|
||||
$tables = $connection->schema()->findTables($connection->prefixTables('{' . $base_table . '}') . '%');
|
||||
|
||||
if ($count) {
|
||||
return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));
|
||||
|
|
|
@ -39,7 +39,8 @@ abstract class ModuleTestBase extends BrowserTestBase {
|
|||
* specified base table. Defaults to TRUE.
|
||||
*/
|
||||
public function assertTableCount($base_table, $count = TRUE) {
|
||||
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
|
||||
$connection = Database::getConnection();
|
||||
$tables = $connection->schema()->findTables($connection->prefixTables('{' . $base_table . '}') . '%');
|
||||
|
||||
if ($count) {
|
||||
return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));
|
||||
|
|
|
@ -71,6 +71,19 @@ class DatabaseLegacyTest extends DatabaseTestBase {
|
|||
$this->assertTrue(db_table_exists('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the db_find_tables() function.
|
||||
*
|
||||
* @expectedDeprecation db_find_tables() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use $injected_database->schema()->findTables($table_expression) instead. See https://www.drupal.org/node/2993033
|
||||
*/
|
||||
public function testDbFindTables() {
|
||||
$expected = [
|
||||
'test_people' => 'test_people',
|
||||
'test_people_copy' => 'test_people_copy',
|
||||
];
|
||||
$this->assertEquals($expected, db_find_tables('test_people%'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the db_set_active() function.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue