You are here

public function DatabaseLegacyTest::testDbQuery in Drupal 8

Tests the db_query() function.

@expectedDeprecation db_query() is deprecated in drupal:8.0.0. It will be removed before drupal:9.0.0. Instead, get a database connection injected into your service from the container and call query() on it. For example, $injected_database->query($query, $args, $options). See https://www.drupal.org/node/2993033

File

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

Class

DatabaseLegacyTest
Deprecation tests cases for the database layer.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDbQuery() {
  $this
    ->assertInstanceOf(StatementInterface::class, db_query('SELECT name FROM {test} WHERE name = :name', [
    ':name' => "John",
  ]));
}