public function SelectTest::testRegularExpressionCondition in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testRegularExpressionCondition()
- 9 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testRegularExpressionCondition()
Tests that filter by 'REGEXP' and 'NOT REGEXP' works as expected.
@dataProvider providerRegularExpressionCondition
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectTest.php, line 524
Class
- SelectTest
- Tests the Select query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testRegularExpressionCondition($expected, $column, $pattern, $operator) {
$database = $this->container
->get('database');
$database
->insert('test')
->fields([
'name' => 'Pete',
'age' => 26,
'job' => '#Drummer',
])
->execute();
$query = $database
->select('test', 't');
$query
->addField('t', 'name');
$query
->condition("t.{$column}", $pattern, $operator);
$result = $query
->execute()
->fetchCol();
sort($result);
$this
->assertEquals($expected, $result);
}