public function ConnectionTest::testQueryTrim in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest::testQueryTrim()
- 10 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest::testQueryTrim()
Test rtrim() of query strings.
@dataProvider provideQueriesToTrim
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ ConnectionTest.php, line 669
Class
- ConnectionTest
- Tests the Connection class.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testQueryTrim($expected, $query, $options) {
$mock_pdo = $this
->getMockBuilder(StubPdo::class)
->setMethods([
'execute',
'prepare',
'setAttribute',
])
->getMock();
$mock_statement = $this
->getMockBuilder(StatementWrapper::class)
->disableOriginalConstructor()
->getMock();
// Ensure that PDO::prepare() is called only once, and with the
// correctly trimmed query string.
$mock_pdo
->expects($this
->once())
->method('prepare')
->with($expected)
->willReturn($mock_statement);
$connection = new StubConnection($mock_pdo, []);
$connection
->query($query, [], $options);
}