public function SelectTest::testEmptyInCondition in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testEmptyInCondition()
Tests thrown exception for IN query conditions with an empty array.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectTest.php, line 583
Class
- SelectTest
- Tests the Select query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testEmptyInCondition() {
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());
}
}