function QueryTest::testScalarSubstitution in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/QueryTest.php \Drupal\system\Tests\Database\QueryTest::testScalarSubstitution()
Tests that we can not pass a scalar value when an array is expected.
File
- core/
modules/ system/ src/ Tests/ Database/ QueryTest.php, line 31 - Contains \Drupal\system\Tests\Database\QueryTest.
Class
- QueryTest
- Tests Drupal's extended prepared statement syntax..
Namespace
Drupal\system\Tests\DatabaseCode
function testScalarSubstitution() {
try {
$names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(
':ages[]' => 25,
))
->fetchAll();
$this
->fail('Array placeholder with scalar argument should result in an exception.');
} catch (\InvalidArgumentException $e) {
$this
->pass('Array placeholder with scalar argument should result in an exception.');
}
}