public function DatabaseLegacyTest::testDbQueryTemporary in Drupal 8
Tests deprecation of the db_query_temporary() function.
@expectedDeprecation db_query_temporary() 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 and call queryTemporary() on it. For example, $injected_database->queryTemporary($query, $args, $options). See https://www.drupal.org/node/2993033
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php, line 469
Class
- DatabaseLegacyTest
- Deprecation tests cases for the database layer.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testDbQueryTemporary() {
$expected = $this->connection
->select('test')
->countQuery()
->execute()
->fetchField();
$name = db_query_temporary('SELECT name FROM {test}');
$count = $this->connection
->select($name)
->countQuery()
->execute()
->fetchField();
$this
->assertSame($expected, $count);
}