function ConnectionTest::testStatementQueryDeprecation

Tests the deprecation of passing a statement object to ::query.

@group legacy

File

core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php, line 142

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testStatementQueryDeprecation() : void {
    $this->expectDeprecation('Passing a StatementInterface object as a $query argument to Drupal\\Core\\Database\\Connection::query is deprecated in drupal:9.2.0 and is removed in drupal:10.0.0. Call the execute method from the StatementInterface object directly instead. See https://www.drupal.org/node/3154439');
    $db = Database::getConnection();
    $stmt = $db->prepareStatement('SELECT * FROM {test}', []);
    $this->assertNotNull($db->query($stmt));
}

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