function ConnectionTest::testPdoStatementClass

Tests the deprecation of \Drupal\Core\Database\Connection::$statementClass.

@group legacy

File

core/tests/Drupal/Tests/Core/Database/ConnectionTest.php, line 738

Class

ConnectionTest
Tests the Connection class.

Namespace

Drupal\Tests\Core\Database

Code

public function testPdoStatementClass() {
  if (PHP_VERSION_ID >= 80000) {
    $this->markTestSkipped('Drupal\\Core\\Database\\Statement is incompatible with PHP 8.0. Remove in https://www.drupal.org/node/3177490');
  }
  $this->expectDeprecation('\\Drupal\\Core\\Database\\Connection::$statementClass is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Database drivers should use or extend StatementWrapper instead, and encapsulate client-level statement objects. See https://www.drupal.org/node/3177488');
  $mock_pdo = $this->createMock(StubPDO::class);
  new StubConnection($mock_pdo, [
    'namespace' => 'Drupal\\Tests\\Core\\Database\\Stub\\Driver',
  ], [
    '"',
    '"',
  ], Statement::class);
}

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