function QueryTest::testScalarSubstitution
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest::testScalarSubstitution()
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest::testScalarSubstitution()
- 10 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest::testScalarSubstitution()
Tests that we can not pass a scalar value when an array is expected.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ QueryTest.php, line 31
Class
- QueryTest
- Tests Drupal's extended prepared statement syntax.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testScalarSubstitution() : void {
try {
$names = $this->connection
->query('SELECT [name] FROM {test} WHERE [age] IN ( :ages[] ) ORDER BY [age]', [
':ages[]' => 25,
])
->fetchAll();
$this->fail('Array placeholder with scalar argument should result in an exception.');
} catch (\Exception $e) {
$this->assertInstanceOf(\InvalidArgumentException::class, $e);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.