StatementWrapperLegacyTest.php in Drupal 9
File
core/tests/Drupal/KernelTests/Core/Database/StatementWrapperLegacyTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Database;
use Drupal\Core\Database\StatementWrapper;
class StatementWrapperLegacyTest extends DatabaseTestBase {
protected $statement;
protected function setUp() : void {
parent::setUp();
$this->statement = $this->connection
->prepareStatement('SELECT * FROM {test}', []);
if (!$this->statement instanceof StatementWrapper) {
$this
->markTestSkipped('This test only works for drivers implementing Drupal\\Core\\Database\\StatementWrapper.');
}
}
public function testQueryString() {
$this
->expectDeprecation('StatementWrapper::$queryString should not be accessed in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488');
$this
->assertStringContainsString('SELECT * FROM ', $this->statement->queryString);
$this
->assertStringContainsString('SELECT * FROM ', $this->statement
->getQueryString());
}
public function testMissingMethod() {
$this
->expectException('\\BadMethodCallException');
$this->statement
->boo();
}
public function testClientStatementMethod() {
$this
->expectDeprecation('StatementWrapper::columnCount should not be called in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488');
$this->statement
->execute();
$this
->assertEquals(4, $this->statement
->columnCount());
}
public function testBindParam() {
$this
->expectDeprecation('StatementWrapper::bindParam should not be called in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488');
$test = NULL;
$this
->assertTrue($this->statement
->bindParam(':name', $test));
}
public function testBindColumn() {
$this
->expectDeprecation('StatementWrapper::bindColumn should not be called in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488');
$test = NULL;
$this
->assertTrue($this->statement
->bindColumn(1, $test));
}
}