public function QueryTest::testScalarSubstitution in Drupal 9
Same name and namespace in other branches
- 8 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 26
Class
- QueryTest
- Tests Drupal's extended prepared statement syntax..
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testScalarSubstitution() {
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);
}
}