function SelectTest::testEmptyInCondition
Tests thrown exception for IN query conditions with an empty array.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectTest.php, line 570
Class
- SelectTest
- Tests the Select query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testEmptyInCondition() : void {
try {
$this->connection
->select('test', 't')
->fields('t')
->condition('age', [], 'IN')
->execute();
$this->fail('Expected exception not thrown');
} catch (InvalidQueryException $e) {
$this->assertEquals("Query condition 'age IN ()' cannot be empty.", $e->getMessage());
}
try {
$this->connection
->select('test', 't')
->fields('t')
->condition('age', [], 'NOT IN')
->execute();
$this->fail('Expected exception not thrown');
} catch (InvalidQueryException $e) {
$this->assertEquals("Query condition 'age NOT IN ()' cannot be empty.", $e->getMessage());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.