function SelectTest::testEmptyInCondition in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/SelectTest.php \Drupal\system\Tests\Database\SelectTest::testEmptyInCondition()
Tests thrown exception for IN query conditions with an empty array.
File
- core/
modules/ system/ src/ Tests/ Database/ SelectTest.php, line 509 - Contains \Drupal\system\Tests\Database\SelectTest.
Class
- SelectTest
- Tests the Select query builder.
Namespace
Drupal\system\Tests\DatabaseCode
function testEmptyInCondition() {
try {
db_select('test', 't')
->fields('t')
->condition('age', array(), 'IN')
->execute();
$this
->fail('Expected exception not thrown');
} catch (InvalidQueryException $e) {
$this
->assertEqual("Query condition 'age IN ()' cannot be empty.", $e
->getMessage());
}
try {
db_select('test', 't')
->fields('t')
->condition('age', array(), 'NOT IN')
->execute();
$this
->fail('Expected exception not thrown');
} catch (InvalidQueryException $e) {
$this
->assertEqual("Query condition 'age NOT IN ()' cannot be empty.", $e
->getMessage());
}
}